2 ms·
It's worse than you might expect, try it with unsigned int ;) $ cc -O3 foo.c $ ./a.out 5e574b68 $ cat foo.c #include <stdio.h> i
by mzs 10y ago
It's worse than you might expect, try it with unsigned int ;)
$ cc -O3 foo.c
$ ./a.out
5e574b68
$ cat foo.c
#include <stdio.h>
int main(int argc, char ** argv) {
unsigned int a = 1;
unsigned int b = 0;
printf("%x\n", a/b);
}
Yes overflow wraps on unsigned as defined, but that example is divide-by-zero which is UB for unsigned too and the compiler is free to optimize there, which LLVM does.