diff mbox

C++ PATCH for c++/46903 (ICE with brace-enclosed function pointer)

Message ID 4D3049AA.9030305@redhat.com
State New
Headers show

Commit Message

Jason Merrill Jan. 14, 2011, 1:03 p.m. UTC
We were calling maybe_constant_value on an unresolved overloaded 
function, which doesn't work.  We can avoid this by just not trying to 
check narrowing on non-arithmetic types.

Tested x86_64-pc-linux-gnu, applied to trunk.
commit 0ad2b45b1743f1e6d3add07f5222d1f1a8bfff71
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jan 12 19:53:10 2011 -0500

    	PR c++/46903
    	* typeck2.c (check_narrowing): Only check arithmetic types.
diff mbox

Patch

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>};