3 ms·
Assuming int is 32 bits wide, `1 << 32` invokes UB.
by valleyer 4y ago
Assuming 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).