|
|
|
|
|
by taneq
3070 days ago
|
|
There are two different things that people can mean when they say "undefined behaviour" in regards to C/C++. One is what you're talking about, with "undefined behaviour" meaning "one of several things could happen, you don't know which, and some of them may be bad." The other is more specifically talking about code that is deemed "undefined behaviour" by the spec. There's a surprising amount of this, and the compiler is explicitly allowed to do anything it wants when encountered, from emitting 'close enough' code to emitting no code at all, to emitting code to order a pizza to your current location. If this is the latter case then it could result in random bits of code mysteriously doing completely unexpected things if the compiler thinks a data race there is possible. This would make it far harder to track down bugs and reason about what code might cause such. |
|