Re:A Guide to Undefined Behavior in C and C++
by muldvarp on Friday August 18, 2023 @06:56AM
(#37173923)
> However, like I said in my first response, this optimization in particular is only valid if the array is definitely accessed incorrectly.
No. The code does not show any undefined behavior if any of the elements of `table` is equal to `v`, because then the loop is ended by an early return. The compiler certainly did not prove that this code always has undefined behavior.
No. The code does not show any undefined behavior if any of the elements of `table` is equal to `v`, because then the loop is ended by an early return. The compiler certainly did not prove that this code always has undefined behavior.