6 ms·
> This honestly depends on what undefined behavior we are talking about. Sometimes it will be guaranteed to behave a certain way on a compiler. That is impleme
by steveklabnik 8y ago
> This honestly depends on what undefined behavior we are talking about. Sometimes it will be guaranteed to behave a certain way on a compiler.
That is implementation defined, not undefined, behavior.
- anfilt 8y agoUndefined as per the spec.
- anfilt 8y agoUndefined as per the spec. Does not mean it does not have a certain behavior on a given implementation. The spec also does mention implemtation defined behavior. However, undefined things still need to be handled.
- doughboy23 8y agoNot really. Undefined means that no purposeful explicit behavior for handling has to occur even within a specific implementation, which means things can blow up randomly just changing some compiler settings or minor things in the environment (or even randomly at runtime).. eg running out of bounds of an array in C is a perfect example of undefined behavior.. no guarantee on what occurs from run to run. Yes obviously time doesn’t stop dead and something happens, but I think that stretches any meaningful definition of “handled”. True, undefined behavior can be implementation defined but that is not a requirement, and it usually is not.
- atq2119 8y agoThat's at least unnecessarily splitting hairs and possibly missing the point, considering that some compilers allow you to turn undefined behaviour into implementation-defined behaviour using an option. -fwrapv comes to mind.