fuhsnn / slimcc

C11 compiler with GNU extensions for x86-64 Linux, working towards C23
MIT License
39 stars 6 forks source link

Constant evaluation wrong right-shift result for 32-bit LHS #43

Closed fuhsnn closed 1 year ago

fuhsnn commented 1 year ago
#include <stdio.h>
int main(void) {
  printf("%d\n", ({ char a[ 3U << 31 >> 31 ]; sizeof(a); })); // expect 1, got 3
  printf("%d\n", ({ char a[ 1 << 31 >> 31 ]; sizeof(a); })); // expect -1, got 1
}