public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/93280] [10 Regression] ICE: in cp_gimplify_expr, at cp /cp-gimplify.c:933 since g:08f594eb399dab06
       [not found] <bug-93280-4@http.gcc.gnu.org/bugzilla/>
@ 2022-03-30 13:51 ` cvs-commit at gcc dot gnu.org
  0 siblings, 0 replies; only message in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-30 13:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:f8c1f29a0b47b4b4a3c1506678f7ca2ce4b7ffbb

commit r12-7919-gf8c1f29a0b47b4b4a3c1506678f7ca2ce4b7ffbb
Author: Marek Polacek <polacek@redhat.com>
Date:   Fri Mar 25 17:46:07 2022 -0400

    c++: ICE with aggregate assignment and DMI [PR104583]

    The attached 93280 test no longer ICEs but looks like it was never added to
the
    testsuite.  The 104583 test, modified so that it closely resembles 93280,
still
    ICEs.

    The problem is that in 104583 we have a value-init from {} (the line A
a{};),
    so this code in convert_like_internal

     7960         /* If we're initializing from {}, it's value-initialization. 
*/
     7961         if (BRACE_ENCLOSED_INITIALIZER_P (expr)
     7962             && CONSTRUCTOR_NELTS (expr) == 0
     7963             && TYPE_HAS_DEFAULT_CONSTRUCTOR (totype)
     7964             && !processing_template_decl)
     7965           {
     7966             bool direct = CONSTRUCTOR_IS_DIRECT_INIT (expr);
    ...
     7974                 TARGET_EXPR_DIRECT_INIT_P (expr) = direct;

    sets TARGET_EXPR_DIRECT_INIT_P.  This does not happen in 93280 where we
    initialize from {0}.

    In 104583, when gimplifying, the d = {}; line, we have

    d = {.a=TARGET_EXPR <D.2474, <<< Unknown tree: aggr_init_expr
      4
      __ct_comp
      D.2474
      (struct A *) <<< Unknown tree: void_cst >>> >>>>}

    where the TARGET_EXPR is the one with TARGET_EXPR_DIRECT_INIT_P set.  In
    gimplify_init_ctor_preeval we do

     4724       FOR_EACH_VEC_SAFE_ELT (v, ix, ce)
     4725         gimplify_init_ctor_preeval (&ce->value, pre_p, post_p, data);

    so we gimplify the TARGET_EXPR, crashing at

     744     case TARGET_EXPR:
     745       /* A TARGET_EXPR that expresses direct-initialization should
have
    been
     746          elided by cp_gimplify_init_expr.  */
     747       gcc_checking_assert (!TARGET_EXPR_DIRECT_INIT_P (*expr_p));

    but there is no INIT_EXPR so cp_gimplify_init_expr was never called!

    Now, the fix for c++/93280
    <https://gcc.gnu.org/pipermail/gcc-patches/2020-January/538414.html>
    says "let's only set TARGET_EXPR_DIRECT_INIT_P when we're using the DMI in
    a constructor." and the comment talks about the full initialization.  Is
    is accurate to say that our TARGET_EXPR does not represent the full
    initialization, because it only initializes the 'a' subobject?  If so,
    then maybe get_nsdmi should clear TARGET_EXPR_DIRECT_INIT_P when in_ctor
    is false.

    I've compared the 93280.s and 104583.s files, they differ only in one
    movl $0, so there are no extra calls and similar.

            PR c++/93280
            PR c++/104583

    gcc/cp/ChangeLog:

            * init.cc (get_nsdmi): Set TARGET_EXPR_DIRECT_INIT_P to in_ctor.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/nsdmi-list7.C: New test.
            * g++.dg/cpp0x/nsdmi-list8.C: New test.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-30 13:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-93280-4@http.gcc.gnu.org/bugzilla/>
2022-03-30 13:51 ` [Bug c++/93280] [10 Regression] ICE: in cp_gimplify_expr, at cp /cp-gimplify.c:933 since g:08f594eb399dab06 cvs-commit at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).