This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] Fix ICE in adjust_temp_type (PR c++/87506)


On Sun, Nov 18, 2018 at 08:33:39PM -0500, Jason Merrill wrote:
> On Fri, Nov 16, 2018 at 4:26 PM Jakub Jelinek <jakub@redhat.com> wrote:
> > I admit this is just a shot in the dark, but I don't see why
> > one couldn't adjust a type of EMPTY_CLASS_EXPR to EMPTY_CLASS_EXPR
> > with a different variant of the same type.
> 
> Makes sense.
> 
> > Or, should I drop that
> >   && TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (temp))
> > part?  We don't really verify something similar for CONSTRUCTORs.
> 
> I suppose it makes sense to assert
> same_type_ignoring_top_level_qualifiers_p for both CONSTRUCTOR and
> EMPTY_CLASS_EXPR.  OK with that change.

Unfortunately that regresses
+FAIL: g++.dg/cpp2a/lambda-uneval8.C  -std=c++2a (internal compiler error)
+FAIL: g++.dg/cpp2a/lambda-uneval8.C  -std=c++2a (test for excess errors)
where one adjust_temp_type call is with
struct A<<lambda closure object><lambda()>()>
as type and a different (including different TYPE_MAIN_VARIANT)
TREE_TYPE (temp), also with printable name
struct A<<lambda closure object><lambda()>()>.

Shall I remove those asserts for now then, or hand it over to you (no idea
what's going on there)?

2018-11-19  Jakub Jelinek  <jakub@redhat.com>

	PR c++/87506
	* constexpr.c (adjust_temp_type): Handle EMPTY_CLASS_EXPR.
	Add assertions for the CONSTRUCTOR case.

	* g++.dg/cpp0x/constexpr-87506.C: New test.

--- gcc/cp/constexpr.c.jj	2018-11-16 21:35:34.551110868 +0100
+++ gcc/cp/constexpr.c	2018-11-19 09:35:06.880386449 +0100
@@ -1280,7 +1280,17 @@ adjust_temp_type (tree type, tree temp)
     return temp;
   /* Avoid wrapping an aggregate value in a NOP_EXPR.  */
   if (TREE_CODE (temp) == CONSTRUCTOR)
-    return build_constructor (type, CONSTRUCTOR_ELTS (temp));
+    {
+      gcc_assert (same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (temp),
+							     type));
+      return build_constructor (type, CONSTRUCTOR_ELTS (temp));
+    }
+  if (TREE_CODE (temp) == EMPTY_CLASS_EXPR)
+    {
+      gcc_assert (same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (temp),
+							     type));
+      return build0 (EMPTY_CLASS_EXPR, type);
+    }
   gcc_assert (scalarish_type_p (type));
   return cp_fold_convert (type, temp);
 }
--- gcc/testsuite/g++.dg/cpp0x/constexpr-87506.C.jj	2018-11-19 09:33:07.795341369 +0100
+++ gcc/testsuite/g++.dg/cpp0x/constexpr-87506.C	2018-11-19 09:33:07.795341369 +0100
@@ -0,0 +1,12 @@
+// PR c++/87506
+// { dg-do compile { target c++11 } }
+
+struct A {};
+struct B { constexpr B (const A) {} };
+struct C : B { using B::B; };
+
+void
+foo ()
+{
+  C c (A{});
+}

> 
> Jason

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]