| ▲ | mbrock 3 hours ago | |||||||
most languages don't even HAVE a specification so in most languages literally EVERYTHING everything is undefined behavior | ||||||||
| ▲ | oersted 3 hours ago | parent [-] | |||||||
UB doesn't mean that it is not specified (actually it is often very well specified), it means that compilers can and do assume that such code patterns will not be present. Those cases may not be considered and can lead to unexpected behaviour. Additionally, some (most?) UB is intentionally UB so that optimisers are free to do fancy tricks assuming that certain cases will never happen. Indeed, this is required for high performance. If they do happen, again, it can lead to unexpected behaviour. PS: Most languages that don't have a specification declare their primary implementation to be specification-as-code. Rust is an example of that, and it does still have UB: the cases that the compiler assumes will not happen. | ||||||||
| ||||||||