4 ms·
Surely undefined behaviour in a language specification is by definition implementation defined? Now the definition could vary between doing something that seem
by josephlord 11y ago
Surely undefined behaviour in a language specification is by definition implementation defined?
Now the definition could vary between doing something that seems obviously correct, crashing or even deleting every file on your disk but whatever it does is up to the compiler implementer.
- tomp 11y agoYou're right, I should have been more specific. By "implementation defined", I actually meant "platform-defined", not "compiler-implementation defined". So, basically, only the native code emitter would take these behaviors into account, and could do whatever (e.g. emulate, crash, emit instructions and hope for the best, ...). But the rest of the compiler pipeline (optimisations) would still need to treat the code as valid.
- pdw 11y ago"Implementation defined" has a specific meaning in the context of the C standard: it means that an implementation needs to define and document a particular behavior. E.g. for GCC: https://gcc.gnu.org/onlinedocs/gcc/C-Implementation.html https://gcc.gnu.org/onlinedocs/gcc/C-Implementation.html For undefined behavior, the standard makes no requirements at all on the compiler.