We’ve all heard the warnings that if you invoke undefined behaviour in C or C++, anything at all can happen.
Is this limited to any runtime behaviour at all, or does this also include any compile-time behaviour? In particular, is a compiler, upon encountering a construct that invokes undefined behaviour, allowed to reject the code (in the absence of other requirements in the standard to do so), or even to crash?
The message above was written by the given user in Lounge<C++> and makes a very valid argument; the standard doesn’t impose any requirements when it comes to code that invokes undefined behavior.
! ! !
undefined-behavior stretches even to the far corner of parsing the input data (ie. code) by the compiler, as verified with the below quotations from both the C++11 and C99 standards.
To answer your question with one sentence;
"in a documented manner characteristic of the environment" is a kind of odd statement, you could pretty much write a compiler documenting that it might crash upon any given code (that’s invalid) to grant it the possibility to crash whenever it wants to.
1. quote from the C++11/C99 standards
###c++11
###c99