diff mbox

[C++] PR 60225

Message ID 53038B36.6000103@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Feb. 18, 2014, 4:32 p.m. UTC
Hi,

as noticed by Marc, this ICE on invalid regression is essentially due to 
the fact that ensure_literal_type_for_constexpr_object, at variance with 
literal_type_p, doesn't use strip_array_types, thus, in:

       if (CLASS_TYPE_P (type) && !COMPLETE_TYPE_P (complete_type (type)))
     /* Don't complain here, we'll complain about incompleteness
         when we try to initialize the variable.  */;
        else if (!literal_type_p (type))

doesn't look through ARRAY_TYPEs and ends up calling literal_type_p, 
which asserts COMPLETE_TYPE_P (t) which ICEs for the testcase at issue. 
I'm proposing restoring the consistency in the below obvious way. Tested 
x86_64-linux.

Thanks,
Paolo.

///////////////////
/cp
2014-02-18  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/60225
	* semantics.c (ensure_literal_type_for_constexpr_object): Use
	strip_array_types.

/testsuite
2014-02-18  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/60225
	* g++.dg/cpp0x/constexpr-ice10.C: New.

Comments

Jason Merrill Feb. 18, 2014, 5:09 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

Index: cp/semantics.c
===================================================================
--- cp/semantics.c	(revision 207837)
+++ cp/semantics.c	(working copy)
@@ -7380,7 +7380,8 @@  ensure_literal_type_for_constexpr_object (tree dec
   if (VAR_P (decl) && DECL_DECLARED_CONSTEXPR_P (decl)
       && !processing_template_decl)
     {
-      if (CLASS_TYPE_P (type) && !COMPLETE_TYPE_P (complete_type (type)))
+      tree stype = strip_array_types (type);
+      if (CLASS_TYPE_P (stype) && !COMPLETE_TYPE_P (complete_type (stype)))
 	/* Don't complain here, we'll complain about incompleteness
 	   when we try to initialize the variable.  */;
       else if (!literal_type_p (type))
Index: testsuite/g++.dg/cpp0x/constexpr-ice10.C
===================================================================
--- testsuite/g++.dg/cpp0x/constexpr-ice10.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/constexpr-ice10.C	(working copy)
@@ -0,0 +1,8 @@ 
+// PR c++/60225
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+  constexpr A() {}
+  static constexpr A a[2] = {};  // { dg-error "incomplete" }
+};