https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105621
Bug ID: 105621 Summary: [13 Regression] Wrong code with -O3 Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: vsevolod.livinskiy at gmail dot com Target Milestone: --- Link to the Compiler Explorer: https://godbolt.org/z/jscK4bTP6 Reproducer: #include <stdio.h> unsigned short a = (unsigned short)31272; int b = -1902905271; unsigned int c = 1618489477U; bool d = (bool)0; void test(unsigned short a, int b, unsigned c) __attribute__((noipa)); void test(unsigned short a, int b, unsigned c) { for (int i = 2; i < 24; i += 3) d = b ? a ? c : 2086607777901731118 : 0; } int main() { test(a, b, c); printf("%d\n", (int)d); if (d != 1) __builtin_abort(); } Error: >$ g++ -O2 driver.cpp && ./a.out 1 >$ g++ -O3 driver.cpp && ./a.out 0 Aborted (core dumped) GCC version 13.0.0 20220516 (69c4b5c519f0df37e4903992644cc29682721bc1)