https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96994

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So, what I see is that expand_default_init calls build_special_member_call for
the default ctor, but because the default ctor is an immediate method, it
returns a TARGET_EXPR with CONSTRUCTOR as the initializer, rather than a call.
expand_default_init doesn't return anything, just appends the rval as
statement, but that doesn't really do anything.
So, one way to fix this would be in expand_default_init check for rval
being a TARGET with TREE_CONSTANT as the initializer and if it is that, build
an INIT_EXPR like it e.g. does that for constexpr ctors.
--- gcc/cp/init.c.jj    2020-09-10 11:24:05.019805303 +0200
+++ gcc/cp/init.c       2020-09-14 15:06:59.467341241 +0200
@@ -1999,6 +1999,9 @@ expand_default_init (tree binfo, tree tr
            rval = build2 (INIT_EXPR, type, exp, e);
        }
     }
+  else if (TREE_CODE (rval) == TARGET_EXPR
+          && TREE_CONSTANT (TARGET_EXPR_INITIAL (rval)))
+    rval = build2 (INIT_EXPR, type, exp, rval);

   /* FIXME put back convert_to_void?  */
   if (TREE_SIDE_EFFECTS (rval))
fixes the testcase

Reply via email to