* [Bug c++/98043] (Regression) ICE in verify_gimpl due to bitpacked enum class (amd64)
2020-11-28 13:54 [Bug c++/98043] New: (Regression) ICE in verify_gimpl due to bitpacked enum class (amd64) BenWiederhake.GitHub at gmx dot de
@ 2020-11-30 8:07 ` rguenth at gcc dot gnu.org
2020-11-30 8:16 ` [Bug c++/98043] [10/11 Regression] ICE ‘verify_gimple’ failed since r10-5122-g6fcb7ebb377f27c7 since r10-5122-g6fcb7ebb377f27c7 marxin at gcc dot gnu.org
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-11-30 8:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98043
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |11.0
Keywords| |ice-checking
Target| |x86_64-*-*
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/98043] [10/11 Regression] ICE ‘verify_gimple’ failed since r10-5122-g6fcb7ebb377f27c7 since r10-5122-g6fcb7ebb377f27c7
2020-11-28 13:54 [Bug c++/98043] New: (Regression) ICE in verify_gimpl due to bitpacked enum class (amd64) BenWiederhake.GitHub at gmx dot de
2020-11-30 8:07 ` [Bug c++/98043] " rguenth at gcc dot gnu.org
@ 2020-11-30 8:16 ` marxin at gcc dot gnu.org
2020-11-30 13:16 ` [Bug c++/98043] [8/9/10/11 Regression] ICE ‘verify_gimple’ failed since r5-3726-g083e891e69429f93b958f6c18e2d52f515bae572 jakub at gcc dot gnu.org
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-11-30 8:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98043
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|(Regression) ICE in |[10/11 Regression] ICE
|verify_gimpl due to |‘verify_gimple’ failed
|bitpacked enum class |since
|(amd64) |r10-5122-g6fcb7ebb377f27c7
| |since
| |r10-5122-g6fcb7ebb377f27c7
Known to work| |9.3.0
CC| |jakub at gcc dot gnu.org,
| |marxin at gcc dot gnu.org
Status|UNCONFIRMED |NEW
Known to fail| |10.2.0, 11.0
Last reconfirmed| |2020-11-30
Ever confirmed|0 |1
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with Jakub's revision.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/98043] [8/9/10/11 Regression] ICE ‘verify_gimple’ failed since r5-3726-g083e891e69429f93b958f6c18e2d52f515bae572
2020-11-28 13:54 [Bug c++/98043] New: (Regression) ICE in verify_gimpl due to bitpacked enum class (amd64) BenWiederhake.GitHub at gmx dot de
2020-11-30 8:07 ` [Bug c++/98043] " rguenth at gcc dot gnu.org
2020-11-30 8:16 ` [Bug c++/98043] [10/11 Regression] ICE ‘verify_gimple’ failed since r10-5122-g6fcb7ebb377f27c7 since r10-5122-g6fcb7ebb377f27c7 marxin at gcc dot gnu.org
@ 2020-11-30 13:16 ` jakub at gcc dot gnu.org
2020-11-30 14:22 ` mpolacek at gcc dot gnu.org
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-11-30 13:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98043
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mpolacek at gcc dot gnu.org
Summary|[10/11 Regression] ICE |[8/9/10/11 Regression] ICE
|‘verify_gimple’ failed |‘verify_gimple’ failed
|since |since
|r10-5122-g6fcb7ebb377f27c7 |r5-3726-g083e891e69429f93b9
| |58f6c18e2d52f515bae572
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The ICE is much older is you remove the for the ICE unnecessary C++20
initializer of the bitfield.
enum class B { A };
struct C { B c : 8; };
bool
foo (C x)
{
switch (x.c)
{
case B::A:
return false;
default:
return true;
}
}
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/98043] [8/9/10/11 Regression] ICE ‘verify_gimple’ failed since r5-3726-g083e891e69429f93b958f6c18e2d52f515bae572
2020-11-28 13:54 [Bug c++/98043] New: (Regression) ICE in verify_gimpl due to bitpacked enum class (amd64) BenWiederhake.GitHub at gmx dot de
` (2 preceding siblings ...)
2020-11-30 13:16 ` [Bug c++/98043] [8/9/10/11 Regression] ICE ‘verify_gimple’ failed since r5-3726-g083e891e69429f93b958f6c18e2d52f515bae572 jakub at gcc dot gnu.org
@ 2020-11-30 14:22 ` mpolacek at gcc dot gnu.org
2020-12-01 23:44 ` mpolacek at gcc dot gnu.org
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-11-30 14:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98043
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Mine then.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/98043] [8/9/10/11 Regression] ICE ‘verify_gimple’ failed since r5-3726-g083e891e69429f93b958f6c18e2d52f515bae572
2020-11-28 13:54 [Bug c++/98043] New: (Regression) ICE in verify_gimpl due to bitpacked enum class (amd64) BenWiederhake.GitHub at gmx dot de
` (3 preceding siblings ...)
2020-11-30 14:22 ` mpolacek at gcc dot gnu.org
@ 2020-12-01 23:44 ` mpolacek at gcc dot gnu.org
2020-12-01 23:44 ` mpolacek at gcc dot gnu.org
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-12-01 23:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98043
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|11.0 |8.5
--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Candidate fix:
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -3711,6 +3711,10 @@ pop_switch (void)
SWITCH_STMT_ALL_CASES_P (cs->switch_stmt) = 1;
if (!cs->break_stmt_seen_p)
SWITCH_STMT_NO_BREAK_P (cs->switch_stmt) = 1;
+ if (SWITCH_STMT_TYPE (cs->switch_stmt)
+ && SCOPED_ENUM_P (SWITCH_STMT_TYPE (cs->switch_stmt)))
+ SWITCH_STMT_TYPE (cs->switch_stmt)
+ = TREE_TYPE (SWITCH_STMT_COND (cs->switch_stmt));
gcc_assert (!cs->in_loop_body_p);
splay_tree_delete (cs->cases);
switch_stack = switch_stack->next;
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/98043] [8/9/10/11 Regression] ICE ‘verify_gimple’ failed since r5-3726-g083e891e69429f93b958f6c18e2d52f515bae572
2020-11-28 13:54 [Bug c++/98043] New: (Regression) ICE in verify_gimpl due to bitpacked enum class (amd64) BenWiederhake.GitHub at gmx dot de
` (4 preceding siblings ...)
2020-12-01 23:44 ` mpolacek at gcc dot gnu.org
@ 2020-12-01 23:44 ` mpolacek at gcc dot gnu.org
2020-12-07 17:38 ` cvs-commit at gcc dot gnu.org
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-12-01 23:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98043
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/98043] [8/9/10/11 Regression] ICE ‘verify_gimple’ failed since r5-3726-g083e891e69429f93b958f6c18e2d52f515bae572
2020-11-28 13:54 [Bug c++/98043] New: (Regression) ICE in verify_gimpl due to bitpacked enum class (amd64) BenWiederhake.GitHub at gmx dot de
` (5 preceding siblings ...)
2020-12-01 23:44 ` mpolacek at gcc dot gnu.org
@ 2020-12-07 17:38 ` cvs-commit at gcc dot gnu.org
2020-12-07 17:51 ` [Bug c++/98043] [8/9/10 " mpolacek at gcc dot gnu.org
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-12-07 17:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98043
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:
https://gcc.gnu.org/g:7482d5a3acb7a8a5564f5cddc4f9d2ebbaea75e4
commit r11-5829-g7482d5a3acb7a8a5564f5cddc4f9d2ebbaea75e4
Author: Marek Polacek <polacek@redhat.com>
Date: Wed Dec 2 10:47:49 2020 -0500
c++: ICE with switch and scoped enum bit-fields [PR98043]
In this testcase we are crashing trying to gimplify a switch, because
the types of the switch condition and case constants have different
TYPE_PRECISIONs.
This started with my r5-3726 fix: SWITCH_STMT_TYPE is supposed to be the
original type of the switch condition before any conversions, so in the
C++ FE we need to use unlowered_expr_type to get the unlowered type of
enum bit-fields.
Normally, the switch type is subject to integral promotions, but here
we have a scoped enum type and those don't promote:
enum class B { A };
struct C { B c : 8; };
switch (x.c) // type B
case B::A: // type int, will be converted to B
Here TREE_TYPE is "signed char" but SWITCH_STMT_TYPE is "B". When
gimplifying this in gimplify_switch_expr, the index type is "B" and
we convert all the case values to "B" in preprocess_case_label_vec,
but SWITCH_COND is of type "signed char": gimple_switch_index should
be the (possibly promoted) type, not the original type, so we gimplify
the "x.c" SWITCH_COND to a SSA_NAME of type "signed char". And then
we crash because the precision of the index type doesn't match the
precision of the case value type.
I think it makes sense to do the following; at the end of pop_switch
we've already issued the switch warnings, and since scoped enums don't
promote, it should be okay to use the type of SWITCH_STMT_COND. The
r5-3726 change was about giving warnings for enum bit-fields anyway.
gcc/cp/ChangeLog:
PR c++/98043
* decl.c (pop_switch): If SWITCH_STMT_TYPE is a scoped enum type,
set it to the type of SWITCH_STMT_COND.
gcc/testsuite/ChangeLog:
PR c++/98043
* g++.dg/cpp0x/enum41.C: New test.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/98043] [8/9/10 Regression] ICE ‘verify_gimple’ failed since r5-3726-g083e891e69429f93b958f6c18e2d52f515bae572
2020-11-28 13:54 [Bug c++/98043] New: (Regression) ICE in verify_gimpl due to bitpacked enum class (amd64) BenWiederhake.GitHub at gmx dot de
` (6 preceding siblings ...)
2020-12-07 17:38 ` cvs-commit at gcc dot gnu.org
@ 2020-12-07 17:51 ` mpolacek at gcc dot gnu.org
2020-12-07 21:03 ` BenWiederhake.GitHub at gmx dot de
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-12-07 17:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98043
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[8/9/10/11 Regression] ICE |[8/9/10 Regression] ICE
|‘verify_gimple’ failed |‘verify_gimple’ failed
|since |since
|r5-3726-g083e891e69429f93b9 |r5-3726-g083e891e69429f93b9
|58f6c18e2d52f515bae572 |58f6c18e2d52f515bae572
--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed on trunk thus far.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/98043] [8/9/10 Regression] ICE ‘verify_gimple’ failed since r5-3726-g083e891e69429f93b958f6c18e2d52f515bae572
2020-11-28 13:54 [Bug c++/98043] New: (Regression) ICE in verify_gimpl due to bitpacked enum class (amd64) BenWiederhake.GitHub at gmx dot de
` (7 preceding siblings ...)
2020-12-07 17:51 ` [Bug c++/98043] [8/9/10 " mpolacek at gcc dot gnu.org
@ 2020-12-07 21:03 ` BenWiederhake.GitHub at gmx dot de
2020-12-07 21:08 ` mpolacek at gcc dot gnu.org
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: BenWiederhake.GitHub at gmx dot de @ 2020-12-07 21:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98043
--- Comment #7 from Ben Wiederhake <BenWiederhake.GitHub at gmx dot de> ---
A testcase got added in PR 98043. Yay!
The testcase contains a `default:` in the switch-case statement. Wasn't it the
case that the bug got triggered by a *lack* of `default:` case?
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/98043] [8/9/10 Regression] ICE ‘verify_gimple’ failed since r5-3726-g083e891e69429f93b958f6c18e2d52f515bae572
2020-11-28 13:54 [Bug c++/98043] New: (Regression) ICE in verify_gimpl due to bitpacked enum class (amd64) BenWiederhake.GitHub at gmx dot de
` (8 preceding siblings ...)
2020-12-07 21:03 ` BenWiederhake.GitHub at gmx dot de
@ 2020-12-07 21:08 ` mpolacek at gcc dot gnu.org
2020-12-08 22:07 ` BenWiederhake.GitHub at gmx dot de
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-12-07 21:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98043
--- Comment #8 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(In reply to Ben Wiederhake from comment #7)
> A testcase got added in PR 98043. Yay!
>
> The testcase contains a `default:` in the switch-case statement. Wasn't it
> the case that the bug got triggered by a *lack* of `default:` case?
No, it was about a type mismatch between the type of the controlling
expression, and the type of the case value.
Thanks for reporting this issue.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/98043] [8/9/10 Regression] ICE ‘verify_gimple’ failed since r5-3726-g083e891e69429f93b958f6c18e2d52f515bae572
2020-11-28 13:54 [Bug c++/98043] New: (Regression) ICE in verify_gimpl due to bitpacked enum class (amd64) BenWiederhake.GitHub at gmx dot de
` (9 preceding siblings ...)
2020-12-07 21:08 ` mpolacek at gcc dot gnu.org
@ 2020-12-08 22:07 ` BenWiederhake.GitHub at gmx dot de
2020-12-08 22:25 ` mpolacek at gcc dot gnu.org
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: BenWiederhake.GitHub at gmx dot de @ 2020-12-08 22:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98043
--- Comment #9 from Ben Wiederhake <BenWiederhake.GitHub at gmx dot de> ---
I totally forgot to say it:
Thanks for fixing it so quickly! :D
When I saw https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97634 I was afraid it
would suffer a slow death – but nope, fixed within a few days. Awesome! Now I
only have to wait for the next release, and my OS's package maintainers. :)
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/98043] [8/9/10 Regression] ICE ‘verify_gimple’ failed since r5-3726-g083e891e69429f93b958f6c18e2d52f515bae572
2020-11-28 13:54 [Bug c++/98043] New: (Regression) ICE in verify_gimpl due to bitpacked enum class (amd64) BenWiederhake.GitHub at gmx dot de
` (10 preceding siblings ...)
2020-12-08 22:07 ` BenWiederhake.GitHub at gmx dot de
@ 2020-12-08 22:25 ` mpolacek at gcc dot gnu.org
2021-01-05 21:30 ` cvs-commit at gcc dot gnu.org
2021-01-05 21:35 ` [Bug c++/98043] [8/9 " mpolacek at gcc dot gnu.org
13 siblings, 0 replies; 15+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-12-08 22:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98043
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |doko at debian dot org
--- Comment #10 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
*** Bug 97634 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/98043] [8/9/10 Regression] ICE ‘verify_gimple’ failed since r5-3726-g083e891e69429f93b958f6c18e2d52f515bae572
2020-11-28 13:54 [Bug c++/98043] New: (Regression) ICE in verify_gimpl due to bitpacked enum class (amd64) BenWiederhake.GitHub at gmx dot de
` (11 preceding siblings ...)
2020-12-08 22:25 ` mpolacek at gcc dot gnu.org
@ 2021-01-05 21:30 ` cvs-commit at gcc dot gnu.org
2021-01-05 21:35 ` [Bug c++/98043] [8/9 " mpolacek at gcc dot gnu.org
13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-05 21:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98043
--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Marek Polacek
<mpolacek@gcc.gnu.org>:
https://gcc.gnu.org/g:48aa64322e824d674b955459ea3816f3047629a3
commit r10-9206-g48aa64322e824d674b955459ea3816f3047629a3
Author: Marek Polacek <polacek@redhat.com>
Date: Wed Dec 2 10:47:49 2020 -0500
c++: ICE with switch and scoped enum bit-fields [PR98043]
In this testcase we are crashing trying to gimplify a switch, because
the types of the switch condition and case constants have different
TYPE_PRECISIONs.
This started with my r5-3726 fix: SWITCH_STMT_TYPE is supposed to be the
original type of the switch condition before any conversions, so in the
C++ FE we need to use unlowered_expr_type to get the unlowered type of
enum bit-fields.
Normally, the switch type is subject to integral promotions, but here
we have a scoped enum type and those don't promote:
enum class B { A };
struct C { B c : 8; };
switch (x.c) // type B
case B::A: // type int, will be converted to B
Here TREE_TYPE is "signed char" but SWITCH_STMT_TYPE is "B". When
gimplifying this in gimplify_switch_expr, the index type is "B" and
we convert all the case values to "B" in preprocess_case_label_vec,
but SWITCH_COND is of type "signed char": gimple_switch_index should
be the (possibly promoted) type, not the original type, so we gimplify
the "x.c" SWITCH_COND to a SSA_NAME of type "signed char". And then
we crash because the precision of the index type doesn't match the
precision of the case value type.
I think it makes sense to do the following; at the end of pop_switch
we've already issued the switch warnings, and since scoped enums don't
promote, it should be okay to use the type of SWITCH_STMT_COND. The
r5-3726 change was about giving warnings for enum bit-fields anyway.
gcc/cp/ChangeLog:
PR c++/98043
* decl.c (pop_switch): If SWITCH_STMT_TYPE is a scoped enum type,
set it to the type of SWITCH_STMT_COND.
gcc/testsuite/ChangeLog:
PR c++/98043
* g++.dg/cpp0x/enum41.C: New test.
(cherry picked from commit 7482d5a3acb7a8a5564f5cddc4f9d2ebbaea75e4)
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/98043] [8/9 Regression] ICE ‘verify_gimple’ failed since r5-3726-g083e891e69429f93b958f6c18e2d52f515bae572
2020-11-28 13:54 [Bug c++/98043] New: (Regression) ICE in verify_gimpl due to bitpacked enum class (amd64) BenWiederhake.GitHub at gmx dot de
` (12 preceding siblings ...)
2021-01-05 21:30 ` cvs-commit at gcc dot gnu.org
@ 2021-01-05 21:35 ` mpolacek at gcc dot gnu.org
13 siblings, 0 replies; 15+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-01-05 21:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98043
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[8/9/10 Regression] ICE |[8/9 Regression] ICE
|‘verify_gimple’ failed |‘verify_gimple’ failed
|since |since
|r5-3726-g083e891e69429f93b9 |r5-3726-g083e891e69429f93b9
|58f6c18e2d52f515bae572 |58f6c18e2d52f515bae572
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #12 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed in GCC 10 too.
^ permalink raw reply [flat|nested] 15+ messages in thread