3 ms·
UB does not mean "anything can happen". UB just means that the language specification makes no assertion about how to handle a given case — the behavior is lit
by DonaldPShimoda 7y ago
UB does not mean "anything can happen".
UB just means that the language specification makes no assertion about how to handle a given case — the behavior is literally just not defined. Any implementation of the language could choose to raise an error for such cases and that would conform correctly to the standard.
- dllthomas 7y agoNote that I specifically said "undefined behavior in C", where it pretty much means exactly that. It is not the same as "implementation defined". It's true that an implementation could in theory respect types even in the case of undefined behavior, but it is not promised by the language spec.