public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114854] New: [14 Regression] ICE with default initializer of const reference member at cp/cp-gimplify.cc:900
@ 2024-04-25 13:41 dani at danielbertalan dot dev
  2024-04-25 14:23 ` [Bug c++/114854] [11/12/13/14 Regression] checking ICE with default initializer of const reference member at cp/cp-gimplify.cc:900 since r10-5822 ppalka at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: dani at danielbertalan dot dev @ 2024-04-25 13:41 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114854
           Summary: [14 Regression] ICE with default initializer of const
                    reference member at cp/cp-gimplify.cc:900
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dani at danielbertalan dot dev
  Target Milestone: ---

Compiling the following code results in an internal compiler error when using
GCC 14 trunk (gcc-14-10094-g0c8e99e5c32). GCC 13.2 is fine with it.

class Vector {
  long m_size;
};
struct ProcessSpawnOptions {
  Vector const &file_actions {};
};

void spawn(ProcessSpawnOptions);
void test() { spawn({}); }


<source>: In function 'void test()':
<source>:9:20: internal compiler error: in cp_gimplify_expr, at
cp/cp-gimplify.cc:900
    9 | void test() { spawn({}); }
      |               ~~~~~^~~~


Godbolt: https://ice.godbolt.org/z/zP3K37476

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/114854] [11/12/13/14 Regression] checking ICE with default initializer of const reference member at cp/cp-gimplify.cc:900 since r10-5822
  2024-04-25 13:41 [Bug c++/114854] New: [14 Regression] ICE with default initializer of const reference member at cp/cp-gimplify.cc:900 dani at danielbertalan dot dev
@ 2024-04-25 14:23 ` ppalka at gcc dot gnu.org
  2024-04-25 15:45 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-04-25 14:23 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |ppalka at gcc dot gnu.org
   Last reconfirmed|                            |2024-04-25
            Summary|[14 Regression] ICE with    |[11/12/13/14 Regression]
                   |default initializer of      |checking ICE with default
                   |const reference member at   |initializer of const
                   |cp/cp-gimplify.cc:900       |reference member at
                   |                            |cp/cp-gimplify.cc:900 since
                   |                            |r10-5822
           Keywords|                            |ice-checking
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Target Milestone|---                         |11.5

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed.  This checking assert failure started ever since the introduction of
the assert, r10-5822-g08f594eb399dab.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/114854] [11/12/13/14 Regression] checking ICE with default initializer of const reference member at cp/cp-gimplify.cc:900 since r10-5822
  2024-04-25 13:41 [Bug c++/114854] New: [14 Regression] ICE with default initializer of const reference member at cp/cp-gimplify.cc:900 dani at danielbertalan dot dev
  2024-04-25 14:23 ` [Bug c++/114854] [11/12/13/14 Regression] checking ICE with default initializer of const reference member at cp/cp-gimplify.cc:900 since r10-5822 ppalka at gcc dot gnu.org
@ 2024-04-25 15:45 ` mpolacek at gcc dot gnu.org
  2024-05-07 21:31 ` [Bug c++/114854] [11/12/13/14/15 " mpolacek at gcc dot gnu.org
  2024-05-15 17:28 ` cvs-commit at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-04-25 15:45 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |mpolacek at gcc dot gnu.org
                 CC|                            |mpolacek at gcc dot gnu.org
           Priority|P3                          |P2

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/114854] [11/12/13/14/15 Regression] checking ICE with default initializer of const reference member at cp/cp-gimplify.cc:900 since r10-5822
  2024-04-25 13:41 [Bug c++/114854] New: [14 Regression] ICE with default initializer of const reference member at cp/cp-gimplify.cc:900 dani at danielbertalan dot dev
  2024-04-25 14:23 ` [Bug c++/114854] [11/12/13/14 Regression] checking ICE with default initializer of const reference member at cp/cp-gimplify.cc:900 since r10-5822 ppalka at gcc dot gnu.org
  2024-04-25 15:45 ` mpolacek at gcc dot gnu.org
@ 2024-05-07 21:31 ` mpolacek at gcc dot gnu.org
  2024-05-15 17:28 ` cvs-commit at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-05-07 21:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I'm using this slightly modified test:

```
class Vector {
  int m_size;
};
struct S {
  const Vector &vec{};
};

void spawn(S);
void test() { spawn({}); }
```

To initialize S we generate:

D.2848 = {.vec=(const struct Vector &) &TARGET_EXPR <D.2840, {.m_size=0}>}

where the TARGET_EXPR is marked TARGET_EXPR_DIRECT_INIT_P, so we expect it to
be elided.  But here it serves as a temporary for Vector{} to which the
reference is bound, so I think it can't be TARGET_EXPR_DIRECT_INIT_P.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/114854] [11/12/13/14/15 Regression] checking ICE with default initializer of const reference member at cp/cp-gimplify.cc:900 since r10-5822
  2024-04-25 13:41 [Bug c++/114854] New: [14 Regression] ICE with default initializer of const reference member at cp/cp-gimplify.cc:900 dani at danielbertalan dot dev
                   ` (2 preceding siblings ...)
  2024-05-07 21:31 ` [Bug c++/114854] [11/12/13/14/15 " mpolacek at gcc dot gnu.org
@ 2024-05-15 17:28 ` cvs-commit at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-15 17:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from GCC 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:1a05332bbac98a4c002bef3fb45a3ad9d56b3a71

commit r15-523-g1a05332bbac98a4c002bef3fb45a3ad9d56b3a71
Author: Marek Polacek <polacek@redhat.com>
Date:   Wed May 8 15:43:58 2024 -0400

    c++: ICE with reference NSDMI [PR114854]

    Here we crash on a cp_gimplify_expr/TARGET_EXPR assert:

          /* A TARGET_EXPR that expresses direct-initialization should have
been
             elided by cp_gimplify_init_expr.  */
          gcc_checking_assert (!TARGET_EXPR_DIRECT_INIT_P (*expr_p));

    the TARGET_EXPR in question is created for the NSDMI in:

      class Vector { int m_size; };
      struct S {
        const Vector &vec{};
      };

    where we first need to create a Vector{} temporary, and then bind the
    vec reference to it.  The temporary is represented by a TARGET_EXPR
    and it cannot be elided.  When we create an object of type S, we get

      D.2848 = {.vec=(const struct Vector &) &TARGET_EXPR <D.2840,
{.m_size=0}>}

    where the TARGET_EXPR is no longer direct-initializing anything.

    Fixed by not setting TARGET_EXPR_DIRECT_INIT_P in
convert_like_internal/ck_user.

            PR c++/114854

    gcc/cp/ChangeLog:

            * call.cc (convert_like_internal) <case ck_user>: Don't set
            TARGET_EXPR_DIRECT_INIT_P.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1y/nsdmi-aggr22.C: New test.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-05-15 17:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-25 13:41 [Bug c++/114854] New: [14 Regression] ICE with default initializer of const reference member at cp/cp-gimplify.cc:900 dani at danielbertalan dot dev
2024-04-25 14:23 ` [Bug c++/114854] [11/12/13/14 Regression] checking ICE with default initializer of const reference member at cp/cp-gimplify.cc:900 since r10-5822 ppalka at gcc dot gnu.org
2024-04-25 15:45 ` mpolacek at gcc dot gnu.org
2024-05-07 21:31 ` [Bug c++/114854] [11/12/13/14/15 " mpolacek at gcc dot gnu.org
2024-05-15 17:28 ` 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).