fuhsnn / slimcc

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

Postfix `++` `--` on boolean yield wrong value #45

Closed fuhsnn closed 1 year ago

fuhsnn commented 1 year ago
#include <stdio.h>

int main(void) {
 _Bool x,y,b;
 b = 1;
 printf("bb plus\n");
 x = b;
 y = b++;
 printf("%d\n", x == y); //expect true, got false

 b = 0;
 printf("bb minus\n");
 x = b;
 y = b--;
 printf("%d\n", x == y); //expect true, got false
}