Consider the example of the problem report
1 template <typename>
2 constexpr bool the_truth () { return true; }
3
4 template <bool>
5 struct Takes_bool { };
6
7 template<bool B>
8 using Alias = Takes_bool<B>;
9
10 template<typename T>
11 struct test { using type = Alias<the_truth<T>()>; };
12
13 int main () {
14 test<int> a;
15
16 return 0;
17 }
that yields the error:
test.cc: In substitution of ‘template<bool B> using Alias = Takes_bool<B> [with bool B = the_truth<int>()]’:
test.cc:11:51: required from ‘struct test<int>’
test.cc:14:13: required from here
test.cc:11:51: error: integral expression ‘the_truth<int>()’ is not constant
struct test { using type = Alias<the_truth<T>()>; };
I think the issue happens in the course of instantiating test<int> at
line 14, when we look into instantiating Alias<the_truth<T>()> (at
line 11) (using instantiate_alias_template) with T = int.
There, when we check the argument 'the_truth<int>()' to see if it
actually is a constant expression, in check_instantiated_arg, we fail
to recognize it constexpr-ness b/c we just look at its TREE_CONSTANT.
At that point, the_truth<int> should have been folded, and it's not,
because instantiate_alias_template forgets to call
coerce_template_parms on its arguments.
Fixed thus, bootstapped and tested on x86_64-unknown-linux-gnu against
trunk.
gcc/cp/
PR c++/55663
* pt.c (coerce_innermost_template_parms): New static function.
(instantiate_alias_template): Use it here.
gcc/testsuite/
PR c++/55663
* g++.dg/cpp0x/alias-decl-31.C: New test.
From-SVN: r195189
| Name |
Last commit
|
Last update |
|---|---|---|
| .. | ||
| ChangeLog | Loading commit data... | |
| ChangeLog-1993 | Loading commit data... | |
| ChangeLog-1994 | Loading commit data... | |
| ChangeLog-1995 | Loading commit data... | |
| ChangeLog-1996 | Loading commit data... | |
| ChangeLog-1997 | Loading commit data... | |
| ChangeLog-1998 | Loading commit data... | |
| ChangeLog-1999 | Loading commit data... | |
| ChangeLog-2000 | Loading commit data... | |
| ChangeLog-2001 | Loading commit data... | |
| ChangeLog-2002 | Loading commit data... | |
| ChangeLog-2003 | Loading commit data... | |
| ChangeLog-2004 | Loading commit data... | |
| ChangeLog-2005 | Loading commit data... | |
| ChangeLog-2006 | Loading commit data... | |
| ChangeLog-2007 | Loading commit data... | |
| ChangeLog-2008 | Loading commit data... | |
| ChangeLog-2009 | Loading commit data... | |
| ChangeLog-2010 | Loading commit data... | |
| ChangeLog-2011 | Loading commit data... | |
| ChangeLog-2012 | Loading commit data... | |
| ChangeLog.ptr | Loading commit data... | |
| ChangeLog.tree-ssa | Loading commit data... | |
| Make-lang.in | Loading commit data... | |
| NEWS | Loading commit data... | |
| call.c | Loading commit data... | |
| cfns.gperf | Loading commit data... | |
| cfns.h | Loading commit data... | |
| class.c | Loading commit data... | |
| config-lang.in | Loading commit data... | |
| cp-gimplify.c | Loading commit data... | |
| cp-lang.c | Loading commit data... | |
| cp-objcp-common.c | Loading commit data... | |
| cp-objcp-common.h | Loading commit data... | |
| cp-tree.def | Loading commit data... | |
| cp-tree.h | Loading commit data... | |
| cvt.c | Loading commit data... | |
| cxx-pretty-print.c | Loading commit data... | |
| cxx-pretty-print.h | Loading commit data... | |
| decl.c | Loading commit data... | |
| decl.h | Loading commit data... | |
| decl2.c | Loading commit data... | |
| dump.c | Loading commit data... | |
| error.c | Loading commit data... | |
| except.c | Loading commit data... | |
| expr.c | Loading commit data... | |
| friend.c | Loading commit data... | |
| g++spec.c | Loading commit data... | |
| init.c | Loading commit data... | |
| lang-specs.h | Loading commit data... | |
| lex.c | Loading commit data... | |
| mangle.c | Loading commit data... | |
| method.c | Loading commit data... | |
| name-lookup.c | Loading commit data... | |
| name-lookup.h | Loading commit data... | |
| operators.def | Loading commit data... | |
| optimize.c | Loading commit data... | |
| parser.c | Loading commit data... | |
| parser.h | Loading commit data... | |
| pt.c | Loading commit data... | |
| ptree.c | Loading commit data... | |
| repo.c | Loading commit data... | |
| rtti.c | Loading commit data... | |
| search.c | Loading commit data... | |
| semantics.c | Loading commit data... | |
| tree.c | Loading commit data... | |
| typeck.c | Loading commit data... | |
| typeck2.c | Loading commit data... |