3 ms·
Yes, which is exactly what I stated. My response was to “ Implementation defined means that the behavior is defined. This is patently not what the existing beha
by ChrisLomont 6y ago
Yes, which is exactly what I stated. My response was to “ Implementation defined means that the behavior is defined. This is patently not what the existing behavior of compilers in the face of integer overflow is.”, implying compilers didn’t have implementation defined behavior. For integer overflow, they do. You just noted this compiler chose an implementation defined behavior. And you don’t need flags for it to choose.
You just stated “ Neither compiler defines it unless you give it flags to specify a certain behavior”. It does define it, exactly as I said, per compiler per platform. No flags made any of them produce implementation defined output. Flags make them produce specific, cross platform behavior.
What exactly are you disputing?
- saagarjha 6y agoThe 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.