News for hackers. Stuff that matters.
Re:Falsehoods programmers believe about undefined behavior by Semaphor on Monday November 28, 2022 @07:48AM (#33772953)
This [0] is the linked article for that point, I don’t do systems programming, so I can’t say I understand if this is trivial or not ;)

[0]: https://www.ralfj.de/blog/2020/07/15/unused-data.html

Re:Falsehoods programmers believe about undefined behavior by account42 on Monday November 28, 2022 @09:54AM (#33774334)
The linked article argues that making storing invalid values in the bool undefined (rather than just using such bools) is important because otherwise the compiler is not allowed to move the code (without adding appropriate checks that it would have been reached). The compiler can only make that transformation if it has no effect on any cases where the code wasn't reached at all, which includes not introducing any new UB in those cases. Predrag conclusion that this means having UB in dead code matters is simply wrong.
Re:Falsehoods programmers believe about undefined behavior by nickitolas on Monday November 28, 2022 @04:14PM (#33779774)
The blog post does not support the assertion that unreachable UB which is not executed is a problem. It starts by saying

> The Rust compiler has a few assumptions that it makes about the behavior of all code. Violations of those assumptions are referred to as Undefined Behavior.

Then it says

> In other words, even just constructing, for example, an invalid bool, is Undefined Behavior—no matter whether that bool is ever actually “used” by the program.

The blog post is talking about how just creating an invalid/trap/niche representation for a value is UB. The act of creating the value is the UB here, not the usage. So, in this case the UB is most definetely reachable and executing (The act of creating the invalid value).