diff mbox

C++ PATCH for c++/50361 (ICE with initializer_list and nullptr)

Message ID 4E720BAD.3000603@redhat.com
State New
Headers show

Commit Message

Jason Merrill Sept. 15, 2011, 2:29 p.m. UTC
Since NULLPTR_TYPE can be a member (though I don't see the point), we 
need to know how to count it.

Tested x86_64-pc-linux-gnu, applying to trunk.
diff mbox

Patch

commit 435875780fc2c4d6b3bc70ca6fb2d2ff8608dfe0
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Sep 13 06:15:16 2011 -0400

    	PR c++/50361
    	* expr.c (count_type_elements): Handle NULLPTR_TYPE.

diff --git a/gcc/expr.c b/gcc/expr.c
index e4bb633..29bf68b 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -5296,6 +5296,7 @@  count_type_elements (const_tree type, bool for_ctor_p)
     case POINTER_TYPE:
     case OFFSET_TYPE:
     case REFERENCE_TYPE:
+    case NULLPTR_TYPE:
       return 1;
 
     case ERROR_MARK:
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr23.C b/gcc/testsuite/g++.dg/cpp0x/nullptr23.C
new file mode 100644
index 0000000..a078269
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr23.C
@@ -0,0 +1,24 @@ 
+// PR c++/50361
+// { dg-options -std=c++0x }
+
+#include <initializer_list>
+
+struct Foo
+{
+  Foo(std::initializer_list<Foo>) { };
+
+  template<class T> Foo(T t) { T u(t); };
+
+private:
+  union Data
+  {
+    Data() : null(nullptr) {}
+
+    std::nullptr_t null;
+  } u_;
+};
+
+int main()
+{
+  Foo f = { {} };
+}