2 ms·
The compiler has not committed to a behavior, it is free to compile that code to trap the next time you try if it so wishes. "Implementation defined" means that
by saagarjha 6y ago
The compiler has not committed to a behavior, it is free to compile that code to trap the next time you try if it so wishes. "Implementation defined" means that on this particular implementation the compiler will always do the same thing.
- ChrisLomont 6y agoAre you claiming if I compile the same code with the same version of the compiler on the same platform the behavior changes from compile to compile? Demonstrate that. If not, then it is as I stated. Certainly compilers can change behavior between versions, listed as breaking changes in the documentation.
- formerly_proven 6y ago> Are you claiming if I compile the same code with the same version of the compiler on the same platform the behavior changes from compile to compile? Your claim ("the same code on the same platform compiled with the exact same compiler generates the same machine code") is a very weak property. Notably it doesn't mean that integer overflow behaves consistently, because it doesn't; the compiler assumes signed integers will never overflow and optimizes on that, so in one spot you might get wrapping, but in another spot the compiler removes your bounds checking, all in the same piece of code, on the same platform, compiled with the exact same compiler.