Re:Falsehoods programmers believe about undefined behavior
by marcosdumay on Tuesday November 29, 2022 @08:05AM
(#33787091)
On C UB is a property of any code, reachable or not, just like the article's references explain.
Why are people fighting this?
And yes, Rust is much more reasonable about it.
Re:Falsehoods programmers believe about undefined behavior
by leni536 on Tuesday November 29, 2022 @08:34AM
(#33787337)
How do you decide if i+1 is UB or not, unless the abstract machine reaches that line with a given value of i?
Re:Falsehoods programmers believe about undefined behavior
by marcosdumay on Tuesday November 29, 2022 @11:34AM
(#33789695)
If you write i+1 anywhere on your code, the compiler is free to assume i is different from the maxumim value and rewrite your code with that in mind.
If you are not satisfied, you can read the article's references (there are 2 for unreacheable code). Or any article about UB here for the last 20 years.
> Right now, we have the fundamental principle that dead code cannot affect program behavior.