News for hackers. Stuff that matters.
Re:Falsehoods programmers believe about undefined behavior by Georgelemental on Monday November 28, 2022 @05:23PM (#33780729)
No, the commenter is right, at least for Rust (can't say for other languages). UB is a property of a particular execution of a program, it happens when code is executed on the abstract machine. As the blog post linked from the article (point 14, footnote 6) states:

> Right now, we have the fundamental principle that dead code cannot affect program behavior.

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.