fuhsnn / slimcc

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

`unsigned` bit-field wrong comparison result #39

Closed fuhsnn closed 1 year ago

fuhsnn commented 1 year ago
#include <stdio.h>
int main(void) {
    struct {
      unsigned field :8;
    } bit = {0};

    printf("%d\n", bit.field > -1 ); // expect true, got false
}