3 ms·
Actually, most of C's "undefined behavior" is left undefined to permit compilers to define whatever behavior is most natural for the target's assembly. Undefine
by breadbox 12y ago
Actually, most of C's "undefined behavior" is left undefined to permit compilers to define whatever behavior is most natural for the target's assembly. Undefined behavior is an issue when you're trying to write portable code. So it's really not surprising that this worked out in the programmer's favor in this situation.
- yoklov 12y agoNope. You're describing implementation-defined behavior. The compiler is free to assume undefined behavior never happens, and optimize it away if it does. This can be a big problem, whether or not you are trying to write portable code. This series (among many other places on the internet) does a good job explaining the problems http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html http://blog.llvm.org/2011/05/what-every-c-programmer-should-...
- breadbox 12y agoI'm familiar with the difference between the two. It's my experience that what I said is largely true for both, and thus my comments.