Closed fuhsnn closed 10 months ago
Expect post-AND, sign-extended value. clang/gcc warn with -Woverflow but still compiles like this:
-Woverflow
#include <stdio.h> int main (void){ struct { int i : 2; _Bool b : 1; unsigned j : 2; } s; int x = s.i = -5; int y = s.j = 5; printf("%d, %d\n", x, y); // expect -1,1; got -5,5 x = s.i += -5; y = s.j += 5; printf("%d, %d\n", x, y); // expect -2,2; got -6,6 }
Expect post-AND, sign-extended value. clang/gcc warn with
-Woverflow
but still compiles like this: