On 1/3/25 9:41 AM, Richard Biener wrote:
Am 03.01.2025 um 16:22 schrieb Jeff Law <jeffreya...@gmail.com>:
So this is an implementation of an idea I had a few years back and prototyped
last spring to fix pr92539.
pr92539 is a false positive Warray-bounds warning triggered by loop unrolling.
The warning is in code that will never execute, but none of the optimizers
clean things up well enough or early enough in the pipeline to avoid the
warning.
To optimize away the code we can take advantage of the fact that we're comparing a value to a
bogus pointer. So for example an EQ comparison against &"aa" + 3 is always
false and a NE comparison against that would always be true.
Forming the pointer invokes UB, the comparison is neither false nor true. I’d
say this is a classical case for path isolation on the pointer forming, not
only discarding either the true or false path of the compare.
The path isolation pass is probably too late in this case?
Yea, significantly too late. One could probably argue that the
unrolling that created this scenario is probably the best place to fix.
Jeff