https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127645
Bug ID: 127645
Summary: [16 Regression] wrong code at -O2
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: xxs_chy at outlook dot com
Target Milestone: ---
Reproducer: https://godbolt.org/z/K8W6bodcY
Reduced case:
#include <stdint.h>
union u0 {
uint8_t f1;
_Bool f2;
};
uint32_t g1;
void *g13;
union u0 g18;
_Bool f9_ld7;
int main()
{
_Bool c12;
uint64_t v15 = 0;
c12 = g1;
lbl_f9_b62:
if (c12) f9_ld7 = *(_Bool *)g13;
g18.f1 = 45;
c12 = v15;
g18 = c12 ? g18 : (union u0){ .f2 = 1 };
if (g18.f1 == 45) return 0;
v15 = 102276357045975979;
goto lbl_f9_b62;
}
This case triggers SIGSEGV at -O2, and terminates normally at -O1.