public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101073] New: [9/10/11/12 Regression] ICE in cxx_eval_constant_expression, at cp/constexpr.c:6941
@ 2021-06-14 17:25 gscfq@t-online.de
  2021-06-15  7:53 ` [Bug c++/101073] " rguenth at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: gscfq@t-online.de @ 2021-06-14 17:25 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101073
           Summary: [9/10/11/12 Regression] ICE in
                    cxx_eval_constant_expression, at cp/constexpr.c:6941
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gscfq@t-online.de
  Target Milestone: ---

With file gcc/testsuite/g++.dg/cpp1y/constexpr-nsdmi9.C and option
-fno-elide-constructors, affects versions down to r6 :


$ g++-12-20210613 -c constexpr-nsdmi9.C -fno-elide-constructors
constexpr-nsdmi9.C:15:19: internal compiler error: in
cxx_eval_constant_expression, at cp/constexpr.c:6941
   15 | constexpr X o = { };
      |                   ^
0x6fae2c cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:6941
0x6fa62e cxx_eval_indirect_ref
        ../../gcc/cp/constexpr.c:5019
0x6fa62e cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:6461
0x6fa4b2 cxx_eval_component_reference
        ../../gcc/cp/constexpr.c:3879
0x6fa4b2 cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:6637
0x6fa62e cxx_eval_indirect_ref
        ../../gcc/cp/constexpr.c:5019
0x6fa62e cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:6461
0x7009eb cxx_eval_store_expression
        ../../gcc/cp/constexpr.c:5327
0x6fa70d cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:6350
0x6f7344 cxx_eval_call_expression
        ../../gcc/cp/constexpr.c:2539
0x6f9ff0 cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:6241
0x6f8fe9 cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:6733
0x6f8fe9 cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:6733
0x6f8fe9 cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:6733
0x6faff0 cxx_eval_indirect_ref
        ../../gcc/cp/constexpr.c:4976
0x6faff0 cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:6461
0x70075f cxx_eval_store_expression
        ../../gcc/cp/constexpr.c:5263
0x6fa70d cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:6350
0x6f7344 cxx_eval_call_expression
        ../../gcc/cp/constexpr.c:2539
0x6f9ff0 cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:6241

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

* [Bug c++/101073] [9/10/11/12 Regression] ICE in cxx_eval_constant_expression, at cp/constexpr.c:6941
  2021-06-14 17:25 [Bug c++/101073] New: [9/10/11/12 Regression] ICE in cxx_eval_constant_expression, at cp/constexpr.c:6941 gscfq@t-online.de
@ 2021-06-15  7:53 ` rguenth at gcc dot gnu.org
  2021-10-02  7:45 ` pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-15  7:53 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |9.5

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

* [Bug c++/101073] [9/10/11/12 Regression] ICE in cxx_eval_constant_expression, at cp/constexpr.c:6941
  2021-06-14 17:25 [Bug c++/101073] New: [9/10/11/12 Regression] ICE in cxx_eval_constant_expression, at cp/constexpr.c:6941 gscfq@t-online.de
  2021-06-15  7:53 ` [Bug c++/101073] " rguenth at gcc dot gnu.org
@ 2021-10-02  7:45 ` pinskia at gcc dot gnu.org
  2021-12-30 16:41 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-02  7:45 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-10-02
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

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

* [Bug c++/101073] [9/10/11/12 Regression] ICE in cxx_eval_constant_expression, at cp/constexpr.c:6941
  2021-06-14 17:25 [Bug c++/101073] New: [9/10/11/12 Regression] ICE in cxx_eval_constant_expression, at cp/constexpr.c:6941 gscfq@t-online.de
  2021-06-15  7:53 ` [Bug c++/101073] " rguenth at gcc dot gnu.org
  2021-10-02  7:45 ` pinskia at gcc dot gnu.org
@ 2021-12-30 16:41 ` jakub at gcc dot gnu.org
  2022-05-27  9:45 ` [Bug c++/101073] [10/11/12/13 " rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-12-30 16:41 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started to ICE with r6-7530-g86461cad6f7b751c19fb96fefc62d8e119c8a351 , before
that it has been rejected.

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

* [Bug c++/101073] [10/11/12/13 Regression] ICE in cxx_eval_constant_expression, at cp/constexpr.c:6941
  2021-06-14 17:25 [Bug c++/101073] New: [9/10/11/12 Regression] ICE in cxx_eval_constant_expression, at cp/constexpr.c:6941 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2021-12-30 16:41 ` jakub at gcc dot gnu.org
@ 2022-05-27  9:45 ` rguenth at gcc dot gnu.org
  2022-06-28 10:45 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-27  9:45 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.5                         |10.4

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9 branch is being closed

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

* [Bug c++/101073] [10/11/12/13 Regression] ICE in cxx_eval_constant_expression, at cp/constexpr.c:6941
  2021-06-14 17:25 [Bug c++/101073] New: [9/10/11/12 Regression] ICE in cxx_eval_constant_expression, at cp/constexpr.c:6941 gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2022-05-27  9:45 ` [Bug c++/101073] [10/11/12/13 " rguenth at gcc dot gnu.org
@ 2022-06-28 10:45 ` jakub at gcc dot gnu.org
  2023-02-08 22:41 ` mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-28 10:45 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.4                        |10.5

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.

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

* [Bug c++/101073] [10/11/12/13 Regression] ICE in cxx_eval_constant_expression, at cp/constexpr.c:6941
  2021-06-14 17:25 [Bug c++/101073] New: [9/10/11/12 Regression] ICE in cxx_eval_constant_expression, at cp/constexpr.c:6941 gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2022-06-28 10:45 ` jakub at gcc dot gnu.org
@ 2023-02-08 22:41 ` mpolacek at gcc dot gnu.org
  2023-02-09 14:16 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-02-08 22:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
A similar test that doesn't use op=:

struct Y
{
  int a;
};

struct X
{
  Y b = Y{1};
  Y c = this->b;
};

constexpr X o = { };
static_assert(o.b.a == 1 && o.c.a == 1, "");

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

* [Bug c++/101073] [10/11/12/13 Regression] ICE in cxx_eval_constant_expression, at cp/constexpr.c:6941
  2021-06-14 17:25 [Bug c++/101073] New: [9/10/11/12 Regression] ICE in cxx_eval_constant_expression, at cp/constexpr.c:6941 gscfq@t-online.de
                   ` (5 preceding siblings ...)
  2023-02-08 22:41 ` mpolacek at gcc dot gnu.org
@ 2023-02-09 14:16 ` mpolacek at gcc dot gnu.org
  2023-02-20 17:45 ` cvs-commit at gcc dot gnu.org
  2023-02-20 17:51 ` mpolacek at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-02-09 14:16 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

* [Bug c++/101073] [10/11/12/13 Regression] ICE in cxx_eval_constant_expression, at cp/constexpr.c:6941
  2021-06-14 17:25 [Bug c++/101073] New: [9/10/11/12 Regression] ICE in cxx_eval_constant_expression, at cp/constexpr.c:6941 gscfq@t-online.de
                   ` (6 preceding siblings ...)
  2023-02-09 14:16 ` mpolacek at gcc dot gnu.org
@ 2023-02-20 17:45 ` cvs-commit at gcc dot gnu.org
  2023-02-20 17:51 ` mpolacek at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-02-20 17:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 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:b2287a4d9a640fdc2caef6a067830ea65044deb7

commit r13-6145-gb2287a4d9a640fdc2caef6a067830ea65044deb7
Author: Marek Polacek <polacek@redhat.com>
Date:   Wed Feb 8 19:13:18 2023 -0500

    c++: ICE with -fno-elide-constructors and trivial fn [PR101073]

    In constexpr-nsdmi3.C, with -fno-elide-constructors, we don't elide
    the Y::Y(const Y&) call used to initialize o.c.  So store_init_value
    -> cxx_constant_init must constexpr-evaluate the call to Y::Y(const Y&)
    in cxx_eval_call_expression.  It's a trivial function, so we do the
    "Shortcut trivial constructor/op=" code and rather than evaluating
    the function, we just create an assignment

      o.c = *(const struct Y &) (const struct Y *) &(&<PLACEHOLDER_EXPR struct
X>)->b

    which is a MODIFY_EXPR, so the preeval code in cxx_eval_store_expression
    clears .ctor and .object, therefore we can't replace the PLACEHOLDER_EXPR
    whereupon we crash at

          /* A placeholder without a referent.  We can get here when
             checking whether NSDMIs are noexcept, or in massage_init_elt;
             just say it's non-constant for now.  */
          gcc_assert (ctx->quiet);

    The PLACEHOLDER_EXPR can also be on the LHS as in constexpr-nsdmi10.C.
    I don't think we can do much here, but I noticed that the whole
    trivial_fn_p (fun) block is only entered when -fno-elide-constructors.
    This is true since GCC 9; it wasn't easy to bisect what changes made it
    so, but r240845 is probably one of them.  -fno-elide-constructors is an
    option for experiments only so it's not clear to me why we'd still want
    to shortcut trivial constructor/op=.  I propose to remove the code and
    add a checking assert to make sure we're not getting a trivial_fn_p
    unless -fno-elide-constructors.

            PR c++/101073

    gcc/cp/ChangeLog:

            * constexpr.cc (cxx_eval_call_expression): Replace shortcutting
trivial
            constructor/op= with a checking assert.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/constexpr-nsdmi3.C: New test.
            * g++.dg/cpp1y/constexpr-nsdmi10.C: New test.

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

* [Bug c++/101073] [10/11/12/13 Regression] ICE in cxx_eval_constant_expression, at cp/constexpr.c:6941
  2021-06-14 17:25 [Bug c++/101073] New: [9/10/11/12 Regression] ICE in cxx_eval_constant_expression, at cp/constexpr.c:6941 gscfq@t-online.de
                   ` (7 preceding siblings ...)
  2023-02-20 17:45 ` cvs-commit at gcc dot gnu.org
@ 2023-02-20 17:51 ` mpolacek at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-02-20 17:51 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed for GCC 13, not backporting.

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

end of thread, other threads:[~2023-02-20 17:51 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-14 17:25 [Bug c++/101073] New: [9/10/11/12 Regression] ICE in cxx_eval_constant_expression, at cp/constexpr.c:6941 gscfq@t-online.de
2021-06-15  7:53 ` [Bug c++/101073] " rguenth at gcc dot gnu.org
2021-10-02  7:45 ` pinskia at gcc dot gnu.org
2021-12-30 16:41 ` jakub at gcc dot gnu.org
2022-05-27  9:45 ` [Bug c++/101073] [10/11/12/13 " rguenth at gcc dot gnu.org
2022-06-28 10:45 ` jakub at gcc dot gnu.org
2023-02-08 22:41 ` mpolacek at gcc dot gnu.org
2023-02-09 14:16 ` mpolacek at gcc dot gnu.org
2023-02-20 17:45 ` cvs-commit at gcc dot gnu.org
2023-02-20 17:51 ` mpolacek 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).