2 ms·
If you don't hit compiler bugs, it's mostly because you're not updating your compiler. Large companies with compiler teams want to use them, so they do update
by astrange 4y ago
If you don't hit compiler bugs, it's mostly because you're not updating your compiler.
Large companies with compiler teams want to use them, so they do update their compiler, so they will find bugs in it.
Btw, what do you think this prints with clang? (Whether the answer is a compiler bug is debatable…)
printf("%#x\n", 1 << 32);
- valleyer 4y agoAssuming int is 32 bits wide, `1 << 32` invokes UB.
- astrange 4y agoIndeed it does. (Spoiler: it prints uninitialized stack memory. A bit closer to demons flying out your nose than you'd expect!)
- valleyer 4y agoFun. Basically, it decides that (due to UB) it can simply not materialize the argument and carry on. On Darwin/x86_64, this actually means that it prints out bits from an "uninitialized" register, specifically %rsi in this case, since that's where the second argument should be (even for variadic functions). Certainly a jarring failure mode! However, if updating your compiler causes you to run into this, you already have a bug in your code (one that clang -- arguably not forcefully enough -- already warns you of).
- Agingcoder 4y agoThis is exactly when I find most of my compiler bugs : every time we upgrade.