Re:Falsehoods programmers believe about undefined behavior
by leni536 on Tuesday November 29, 2022 @02:34AM
(#33784675)
Point 14 explicitly says UB in dead code.
The implicit assumption is no UB in live code, otherwise the UB in dead code is a red herring.
So the UB is never reached, by the definition of dead code.
Unreachable UB is fine.
If this wasn't the intended message of point 14, then it's phrased wrong.
Re:Falsehoods programmers believe about undefined behavior
by oconnor663 on Tuesday November 29, 2022 @04:10AM
(#33785317)
Yeah the format of the article makes this mistake extra confusing. The statement in point 14 is in fact true, but the whole premise is that all these statements are supposed to be false.
So we could say, unreachable UB is fine, but if you do reach it, then it doesn't matter when you reached it.