https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127529
Bug ID: 127529
Summary: ICE in gimplify_expr with __transaction_atomic around
an elvis (?:) expression
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: ice-on-valid-code
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: captainnemo9292 at gmail dot com
Target Milestone: ---
Target: x86_64-linux-gnu
int b(int);
int a(int x) { return __transaction_atomic (b(x) ?: x); }
$ gcc -fgnu-tm -c t.c
t.c:2:45: internal compiler error: in gimplify_expr, at gimplify.cc:21371
gimplify_expr
gimplify_expr
gimplify_stmt
https://godbolt.org/z/YnoWxcEnf
The GNU ?: with omitted middle operand wraps the condition in a SAVE_EXPR
that is shared between the condition and the result. Inside a
__transaction_atomic expression the TM lowering moves the expression into
the transaction body, and gimplify_expr later meets a tree code it does not
expect at that point (the gcc_unreachable at gimplify.cc:21371). The same
ICE happens without -fgnu-tm after the "without transactional memory support
enabled" error. PR100556 shows the same assertion for
__transaction_atomic (a == 1); the ?: form may be the same missing case.
gcc trunk 17.0.0 20260920 and gcc 13.