https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110080
--- Comment #1 from Theodoros Theodoridis <theodort at inf dot ethz.ch> ---
Oops, the first code snippet is wrong in the original post:
void foo(void);
static unsigned char a = 131;
static int *b;
static int **c = &b;
static void d(int e, unsigned f) {
int *g;
if (!e){ // <------------------------ if (!e) is correct
for (; a; ++a)
for (e = 0; 0;)
;
g = &e;
int **h = &g;
if (**h) {
foo();
}
}
*c = &e;
}
int main() { d(4 & a, a); }
this is also the correct assembly for gcc trunk/13.1/12.3 at -Os:
main:
movb a(%rip), %al
testb $4, %al
jne .L5
xorl %edx, %edx
.L2:
testb %al, %al
je .L12
incl %eax
movb $1, %dl
jmp .L2
.L12:
testb %dl, %dl
je .L5
movb $0, a(%rip)
.L5:
leaq -4(%rsp), %rax
movq %rax, b(%rip)
xorl %eax, %eax
ret
a:
.byte -125
the code with the _builtin_unreachable and the rest are correct