https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105189
Bug ID: 105189
Summary: [9/10/11/12 Regression] Wrong code with -O1
Product: gcc
Version: 12.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://gcc.godbolt.org/z/zGn1a49KT
Reproducer:
#include <stdio.h>
int var_16 = -1;
int a(int b) { return b; }
int main() {
int c = (unsigned int)a(var_16) >= 0 && 4;
printf("%d\n", c);
if (c != 1)
__builtin_abort();
}
Error:
>$ g++ -O1 driver.cpp && ./a.out
0
>$ g++ -O0 driver.cpp && ./a.out
1
gcc version 12.0.1 20220406 (git://gcc.gnu.org/git/gcc.git:master
9fd377a747375a82912bd81c67b275301489785c)