https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103376
--- Comment #7 from Zhendong Su <zhendong.su at inf dot ethz.ch> ---
A couple of additional tests for the same issue:
(1) at -Os and above
[622] % gcctk -O1 small.c; ./a.out
[623] % gcctk -Os small.c; ./a.out
Aborted
[624] % cat small.c
long a = 2653121401;
unsigned char b;
int c;
int main() {
b = a;
c = ~(((a ^ b) + 2) ^ 254);
if (c > 1641845765)
__builtin_abort();
return 0;
}
(2) at -O2 and -O3
[511] % gcctk -Os small.c; ./a.out
[512] % gcctk -O2 small.c; ./a.out
Segmentation fault
[513] %
[513] % cat small.c
int printf(const char *, ...);
int a = 1, *b;
int main() {
int c = a;
if (a == 2)
printf("0");
a = a ^ c;
if (a)
a++;
if (a && *b)
return a;
return 0;
}