Re:Undefined behavior in C is a reading error
by UncleMeat on Thursday May 20, 2021 @03:17PM
(#27225750)
IMO, implementation defined is worse. It is still a time bomb but now it is a time bomb that you cannot use compiler errors to prevent automatically.
[ Parent
| on HN ]
How so? The implementation can, and perhaps should, define that it errors. Whatever behaviour you're worried about a compiler doing for implementation-defined behaviour, it could do exactly the same thing if the behaviour was undefined.
Re:Undefined behavior in C is a reading error
by UncleMeat on Thursday May 20, 2021 @09:14PM
(#27229449)
Implementation defined behavior can only ever produce compiler warnings, which you can choose to be commit blockers if you want. But if a compiler can prove that UB can happen then it can completely prevent you from building that program.
> But if a compiler can prove that UB can happen then it can completely prevent you from building that program.
Not really; the C standard requires implementations to have particular behaviour for executions which do not encounter undefined behaviour, so an implementation still has to do the right thing for valid cases. So if there's even one possible set of user input etc. for which the program has defined behaviour then a compiler has to produce an executable.