re PR c++/68890 (ICE in verify_ctor_sanity, at cp/constexpr.c:2113)
authorJason Merrill <jason@redhat.com>
Mon, 15 Feb 2016 21:13:57 +0000 (16:13 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 15 Feb 2016 21:13:57 +0000 (16:13 -0500)
PR c++/68890

* constexpr.c (verify_ctor_sanity): Remove CONSTRUCTOR_NELTS check.

From-SVN: r233430

gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/testsuite/g++.dg/cpp0x/constexpr-value5.C [new file with mode: 0644]

index 3f2177f87ec5fb43bff73d6ebf1609a294da7e9e..85473df23d5a961e9bae082d1a6846315a582eb4 100644 (file)
@@ -1,3 +1,8 @@
+2016-02-15  Jason Merrill  <jason@redhat.com>
+
+       PR c++/68890
+       * constexpr.c (verify_ctor_sanity): Remove CONSTRUCTOR_NELTS check.
+
 2016-02-12  Patrick Palka  <ppalka@gcc.gnu.org>
 
        PR c++/69098
index 85fc64ed8cc90d2012a888c5cad9f16bb9dd5702..11037fb62ca7bc88d6448ce10e5855412c74ed17 100644 (file)
@@ -2202,7 +2202,8 @@ verify_ctor_sanity (const constexpr_ctx *ctx, tree type)
   gcc_assert (ctx->ctor);
   gcc_assert (same_type_ignoring_top_level_qualifiers_p
              (type, TREE_TYPE (ctx->ctor)));
-  gcc_assert (CONSTRUCTOR_NELTS (ctx->ctor) == 0);
+  /* We used to check that ctx->ctor was empty, but that isn't the case when
+     the object is zero-initialized before calling the constructor.  */
   if (ctx->object)
     gcc_assert (same_type_ignoring_top_level_qualifiers_p
                (type, TREE_TYPE (ctx->object)));
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-value5.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-value5.C
new file mode 100644 (file)
index 0000000..8928b67
--- /dev/null
@@ -0,0 +1,18 @@
+// PR c++/68890
+// { dg-do compile { target c++11 } }
+
+class ptr;
+template <long _Nm> struct A { typedef ptr _Type[_Nm]; };
+template <long _Nm> struct B { typename A<_Nm>::_Type _M_elems; };
+template <long N> class FixedVector : B<N> {
+public:
+  typedef B<1> base;
+  constexpr FixedVector() : base(), size_() {}
+  char size_;
+};
+class ptr {
+public:
+  constexpr ptr() : px_(){};
+  int px_;
+};
+FixedVector<1> a;