public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97328] New: [ICE] internal compiler error: in verify_ctor_sanity, at cp/constexpr.c:3995
@ 2020-10-07 23:36 ldalessandro at gmail dot com
  2020-10-08 12:02 ` [Bug c++/97328] [10/11 Regression] ICE in verify_ctor_sanity, at cp/constexpr.c:3995 since r10-7313-gb599bf9d6d1e180d marxin at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: ldalessandro at gmail dot com @ 2020-10-07 23:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97328
           Summary: [ICE] internal compiler error: in verify_ctor_sanity,
                    at cp/constexpr.c:3995
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ldalessandro at gmail dot com
  Target Milestone: ---

Following code causes ICE, but *ONLY* when explicitly passing `-std=c++20`.

```
template <typename T, int N>
struct vector {
    union storage { 
        T t; 
        constexpr  storage() {}
    } data[N];
};

constexpr auto foo() {
    vector<char, 8> i;
    return i;
}
auto f = foo();
```

See https://godbolt.org/z/hYYeq8.

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

* [Bug c++/97328] [10/11 Regression] ICE in verify_ctor_sanity, at cp/constexpr.c:3995 since r10-7313-gb599bf9d6d1e180d
  2020-10-07 23:36 [Bug c++/97328] New: [ICE] internal compiler error: in verify_ctor_sanity, at cp/constexpr.c:3995 ldalessandro at gmail dot com
@ 2020-10-08 12:02 ` marxin at gcc dot gnu.org
  2020-10-08 12:02 ` marxin at gcc dot gnu.org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-10-08 12:02 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2020-10-08
             Status|UNCONFIRMED                 |NEW
            Summary|[ICE] internal compiler     |[10/11 Regression] ICE in
                   |error: in                   |verify_ctor_sanity, at
                   |verify_ctor_sanity, at      |cp/constexpr.c:3995 since
                   |cp/constexpr.c:3995         |r10-7313-gb599bf9d6d1e180d
                 CC|                            |marxin at gcc dot gnu.org,
                   |                            |ppalka at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed, started with r10-7313-gb599bf9d6d1e180d.

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

* [Bug c++/97328] [10/11 Regression] ICE in verify_ctor_sanity, at cp/constexpr.c:3995 since r10-7313-gb599bf9d6d1e180d
  2020-10-07 23:36 [Bug c++/97328] New: [ICE] internal compiler error: in verify_ctor_sanity, at cp/constexpr.c:3995 ldalessandro at gmail dot com
  2020-10-08 12:02 ` [Bug c++/97328] [10/11 Regression] ICE in verify_ctor_sanity, at cp/constexpr.c:3995 since r10-7313-gb599bf9d6d1e180d marxin at gcc dot gnu.org
@ 2020-10-08 12:02 ` marxin at gcc dot gnu.org
  2020-10-08 13:11 ` ppalka at gcc dot gnu.org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-10-08 12:02 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |10.3
      Known to work|                            |9.3.0
      Known to fail|                            |10.2.0, 11.0

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

* [Bug c++/97328] [10/11 Regression] ICE in verify_ctor_sanity, at cp/constexpr.c:3995 since r10-7313-gb599bf9d6d1e180d
  2020-10-07 23:36 [Bug c++/97328] New: [ICE] internal compiler error: in verify_ctor_sanity, at cp/constexpr.c:3995 ldalessandro at gmail dot com
  2020-10-08 12:02 ` [Bug c++/97328] [10/11 Regression] ICE in verify_ctor_sanity, at cp/constexpr.c:3995 since r10-7313-gb599bf9d6d1e180d marxin at gcc dot gnu.org
  2020-10-08 12:02 ` marxin at gcc dot gnu.org
@ 2020-10-08 13:11 ` ppalka at gcc dot gnu.org
  2020-10-08 18:46 ` ppalka at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-10-08 13:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org

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

* [Bug c++/97328] [10/11 Regression] ICE in verify_ctor_sanity, at cp/constexpr.c:3995 since r10-7313-gb599bf9d6d1e180d
  2020-10-07 23:36 [Bug c++/97328] New: [ICE] internal compiler error: in verify_ctor_sanity, at cp/constexpr.c:3995 ldalessandro at gmail dot com
                   ` (2 preceding siblings ...)
  2020-10-08 13:11 ` ppalka at gcc dot gnu.org
@ 2020-10-08 18:46 ` ppalka at gcc dot gnu.org
  2020-10-08 18:51 ` mpolacek at gcc dot gnu.org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-10-08 18:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
When 'storage' is a struct instead of a union, i.e. for the testcase

template <typename T, int N>
struct vector {
    struct storage { 
        T t; 
        constexpr  storage() {}
    } data[N];
};

constexpr auto foo() {
    vector<char, 8> i;
    return i;
}
auto f = foo();

we started to ICE earlier, since r279019:

   PR c++/91353 - P1331R2: Allow trivial default init in constexpr contexts.

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

* [Bug c++/97328] [10/11 Regression] ICE in verify_ctor_sanity, at cp/constexpr.c:3995 since r10-7313-gb599bf9d6d1e180d
  2020-10-07 23:36 [Bug c++/97328] New: [ICE] internal compiler error: in verify_ctor_sanity, at cp/constexpr.c:3995 ldalessandro at gmail dot com
                   ` (3 preceding siblings ...)
  2020-10-08 18:46 ` ppalka at gcc dot gnu.org
@ 2020-10-08 18:51 ` mpolacek at gcc dot gnu.org
  2020-10-08 19:20 ` ppalka at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-10-08 18:51 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(In reply to Patrick Palka from comment #2)
> When 'storage' is a struct instead of a union, i.e. for the testcase
> 
> template <typename T, int N>
> struct vector {
>     struct storage { 
>         T t; 
>         constexpr  storage() {}
>     } data[N];
> };
> 
> constexpr auto foo() {
>     vector<char, 8> i;
>     return i;
> }
> auto f = foo();
> 
> we started to ICE earlier, since r279019:
> 
>    PR c++/91353 - P1331R2: Allow trivial default init in constexpr contexts.

Ah.  Feel free to hand this PR to me then (that is, if you don't want it
anymore).

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

* [Bug c++/97328] [10/11 Regression] ICE in verify_ctor_sanity, at cp/constexpr.c:3995 since r10-7313-gb599bf9d6d1e180d
  2020-10-07 23:36 [Bug c++/97328] New: [ICE] internal compiler error: in verify_ctor_sanity, at cp/constexpr.c:3995 ldalessandro at gmail dot com
                   ` (4 preceding siblings ...)
  2020-10-08 18:51 ` mpolacek at gcc dot gnu.org
@ 2020-10-08 19:20 ` ppalka at gcc dot gnu.org
  2020-10-08 21:46 ` ppalka at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-10-08 19:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Marek Polacek from comment #3)
> (In reply to Patrick Palka from comment #2)
> > When 'storage' is a struct instead of a union, i.e. for the testcase
> > 
> > template <typename T, int N>
> > struct vector {
> >     struct storage { 
> >         T t; 
> >         constexpr  storage() {}
> >     } data[N];
> > };
> > 
> > constexpr auto foo() {
> >     vector<char, 8> i;
> >     return i;
> > }
> > auto f = foo();
> > 
> > we started to ICE earlier, since r279019:
> > 
> >    PR c++/91353 - P1331R2: Allow trivial default init in constexpr contexts.
> 
> Ah.  Feel free to hand this PR to me then (that is, if you don't want it
> anymore).

I have a fix, I think :) Will post it to the ML soon.

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

* [Bug c++/97328] [10/11 Regression] ICE in verify_ctor_sanity, at cp/constexpr.c:3995 since r10-7313-gb599bf9d6d1e180d
  2020-10-07 23:36 [Bug c++/97328] New: [ICE] internal compiler error: in verify_ctor_sanity, at cp/constexpr.c:3995 ldalessandro at gmail dot com
                   ` (5 preceding siblings ...)
  2020-10-08 19:20 ` ppalka at gcc dot gnu.org
@ 2020-10-08 21:46 ` ppalka at gcc dot gnu.org
  2020-10-12 11:45 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-10-08 21:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
https://gcc.gnu.org/pipermail/gcc-patches/2020-October/555850.html

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

* [Bug c++/97328] [10/11 Regression] ICE in verify_ctor_sanity, at cp/constexpr.c:3995 since r10-7313-gb599bf9d6d1e180d
  2020-10-07 23:36 [Bug c++/97328] New: [ICE] internal compiler error: in verify_ctor_sanity, at cp/constexpr.c:3995 ldalessandro at gmail dot com
                   ` (6 preceding siblings ...)
  2020-10-08 21:46 ` ppalka at gcc dot gnu.org
@ 2020-10-12 11:45 ` rguenth at gcc dot gnu.org
  2020-10-22 11:41 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-10-12 11:45 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

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

* [Bug c++/97328] [10/11 Regression] ICE in verify_ctor_sanity, at cp/constexpr.c:3995 since r10-7313-gb599bf9d6d1e180d
  2020-10-07 23:36 [Bug c++/97328] New: [ICE] internal compiler error: in verify_ctor_sanity, at cp/constexpr.c:3995 ldalessandro at gmail dot com
                   ` (7 preceding siblings ...)
  2020-10-12 11:45 ` rguenth at gcc dot gnu.org
@ 2020-10-22 11:41 ` cvs-commit at gcc dot gnu.org
  2020-10-22 11:53 ` [Bug c++/97328] [10 " ppalka at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-10-22 11:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:3d423c6f6a69d87ad52ba3af75f3debd8a8b8810

commit r11-4231-g3d423c6f6a69d87ad52ba3af75f3debd8a8b8810
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Oct 22 07:40:40 2020 -0400

    c++: Handle RANGE_EXPR index in init_subob_ctx [PR97328]

    In the testcase below, we're ICEing during constexpr evaluation of the
    CONSTRUCTOR {.data={{}, [1 ... 7]={}}} of type 'vector'.  The interesting
    thing about this CONSTRUCTOR is that it has a RANGE_EXPR index for an
    element initializer which doesn't satisfy reduced_constant_expression_p
    (because the field 't' is uninitialized).

    This is a problem because init_subob_ctx currently punts on setting up a
    sub-aggregate initialization context when given a RANGE_EXPR index, so
    we later trip over the asserts in verify_ctor_sanity when recursing into
    cxx_eval_bare_aggregate on this element initializer.

    Fix this by making init_subob_ctx set up an appropriate initialization
    context when supplied a RANGE_EXPR index.

    gcc/cp/ChangeLog:

            PR c++/97328
            * constexpr.c (init_subob_ctx): Don't punt on RANGE_EXPR
            indexes, instead build a sub-aggregate initialization context
            with no subobject.

    gcc/testsuite/ChangeLog:

            PR c++/97328
            * g++.dg/cpp2a/constexpr-init19.C: New test.
            * g++.dg/cpp2a/constexpr-init20.C: New test.

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

* [Bug c++/97328] [10 Regression] ICE in verify_ctor_sanity, at cp/constexpr.c:3995 since r10-7313-gb599bf9d6d1e180d
  2020-10-07 23:36 [Bug c++/97328] New: [ICE] internal compiler error: in verify_ctor_sanity, at cp/constexpr.c:3995 ldalessandro at gmail dot com
                   ` (8 preceding siblings ...)
  2020-10-22 11:41 ` cvs-commit at gcc dot gnu.org
@ 2020-10-22 11:53 ` ppalka at gcc dot gnu.org
  2020-10-22 16:36 ` cvs-commit at gcc dot gnu.org
  2020-10-22 16:39 ` ppalka at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-10-22 11:53 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[10/11 Regression] ICE in   |[10 Regression] ICE in
                   |verify_ctor_sanity, at      |verify_ctor_sanity, at
                   |cp/constexpr.c:3995 since   |cp/constexpr.c:3995 since
                   |r10-7313-gb599bf9d6d1e180d  |r10-7313-gb599bf9d6d1e180d

--- Comment #7 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 11 so far.

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

* [Bug c++/97328] [10 Regression] ICE in verify_ctor_sanity, at cp/constexpr.c:3995 since r10-7313-gb599bf9d6d1e180d
  2020-10-07 23:36 [Bug c++/97328] New: [ICE] internal compiler error: in verify_ctor_sanity, at cp/constexpr.c:3995 ldalessandro at gmail dot com
                   ` (9 preceding siblings ...)
  2020-10-22 11:53 ` [Bug c++/97328] [10 " ppalka at gcc dot gnu.org
@ 2020-10-22 16:36 ` cvs-commit at gcc dot gnu.org
  2020-10-22 16:39 ` ppalka at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-10-22 16:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:8094f781c35b64da68245d351b85546cca5b809b

commit r10-8938-g8094f781c35b64da68245d351b85546cca5b809b
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Oct 22 07:40:40 2020 -0400

    c++: Handle RANGE_EXPR index in init_subob_ctx [PR97328]

    In the testcase below, we're ICEing during constexpr evaluation of the
    CONSTRUCTOR {.data={{}, [1 ... 7]={}}} of type 'vector'.  The interesting
    thing about this CONSTRUCTOR is that it has a RANGE_EXPR index for an
    element initializer which doesn't satisfy reduced_constant_expression_p
    (because the field 't' is uninitialized).

    This is a problem because init_subob_ctx currently punts on setting up a
    sub-aggregate initialization context when given a RANGE_EXPR index, so
    we later trip over the asserts in verify_ctor_sanity when recursing into
    cxx_eval_bare_aggregate on this element initializer.

    Fix this by making init_subob_ctx set up an appropriate initialization
    context when supplied a RANGE_EXPR index.

    gcc/cp/ChangeLog:

            PR c++/97328
            * constexpr.c (init_subob_ctx): Don't punt on RANGE_EXPR
            indexes, instead build a sub-aggregate initialization context
            with no subobject.

    gcc/testsuite/ChangeLog:

            PR c++/97328
            * g++.dg/cpp2a/constexpr-init19.C: New test.
            * g++.dg/cpp2a/constexpr-init20.C: New test.

    (cherry picked from commit 3d423c6f6a69d87ad52ba3af75f3debd8a8b8810)

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

* [Bug c++/97328] [10 Regression] ICE in verify_ctor_sanity, at cp/constexpr.c:3995 since r10-7313-gb599bf9d6d1e180d
  2020-10-07 23:36 [Bug c++/97328] New: [ICE] internal compiler error: in verify_ctor_sanity, at cp/constexpr.c:3995 ldalessandro at gmail dot com
                   ` (10 preceding siblings ...)
  2020-10-22 16:36 ` cvs-commit at gcc dot gnu.org
@ 2020-10-22 16:39 ` ppalka at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-10-22 16:39 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #9 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 10.3+.

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

end of thread, other threads:[~2020-10-22 16:39 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-07 23:36 [Bug c++/97328] New: [ICE] internal compiler error: in verify_ctor_sanity, at cp/constexpr.c:3995 ldalessandro at gmail dot com
2020-10-08 12:02 ` [Bug c++/97328] [10/11 Regression] ICE in verify_ctor_sanity, at cp/constexpr.c:3995 since r10-7313-gb599bf9d6d1e180d marxin at gcc dot gnu.org
2020-10-08 12:02 ` marxin at gcc dot gnu.org
2020-10-08 13:11 ` ppalka at gcc dot gnu.org
2020-10-08 18:46 ` ppalka at gcc dot gnu.org
2020-10-08 18:51 ` mpolacek at gcc dot gnu.org
2020-10-08 19:20 ` ppalka at gcc dot gnu.org
2020-10-08 21:46 ` ppalka at gcc dot gnu.org
2020-10-12 11:45 ` rguenth at gcc dot gnu.org
2020-10-22 11:41 ` cvs-commit at gcc dot gnu.org
2020-10-22 11:53 ` [Bug c++/97328] [10 " ppalka at gcc dot gnu.org
2020-10-22 16:36 ` cvs-commit at gcc dot gnu.org
2020-10-22 16:39 ` ppalka 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).