fuhsnn / slimcc

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

Float NAN values yield wrong result when cast to bool or as controlling expression #87

Closed fuhsnn closed 2 weeks ago

fuhsnn commented 2 weeks ago
#include <stdio.h>

int main(void) {
    printf("%d\n", (_Bool)(0.0/0.0)); // expect 1, got 0
    printf("%d\n", (0.0/0.0) ? 1 : 0); // expect 1, got 0
}
fuhsnn commented 2 weeks ago

Fixed with https://github.com/fuhsnn/widcc/commit/d8981c320d55dc9acbc5f1f7c395def51987ec38