Message ID | 4D3049AA.9030305@redhat.com |
---|---|
State | New |
Headers | show |
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 3d65939..82218f0 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -717,6 +717,9 @@ check_narrowing (tree type, tree init) bool ok = true; REAL_VALUE_TYPE d; + if (!ARITHMETIC_TYPE_P (type)) + return; + init = maybe_constant_value (init); if (TREE_CODE (type) == INTEGER_TYPE diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-regress1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-regress1.C new file mode 100644 index 0000000..a6fe399 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-regress1.C @@ -0,0 +1,10 @@ +// PR c++/46903 +// This isn't C++0x code, but it was breaking in C++0x mode. +// { dg-options -std=c++0x } + +struct A {}; +struct B { + void *(*a)(); +}; +template <typename T> void *CreateA() {} +B b = {CreateA<A>};