PING [PATCH] correct handling of offsets in PHI expressions [PR103215]

Martin Sebor
Mon Nov 29 16:01:44 GMT 2021


On 11/22/21 4:54 PM, Martin Sebor wrote:
> In an effort to avoid false positives while still detecting
> certain out-of-bounds accesses the warning code that handles
> PHI nodes chooses the operand with the most space remaining
> as the one representative of the PHI.  That's not right when
> the offsets into the operands are unequal, because it overly
> constrains the range of offsets that can be substracted from
> the pointer.
> The attached change corrects the logic here to not only use
> the size of the largest operand but also to extend the range
> of offsets into it to reflect all operand.  Unfortunately,
> as a result of the more conservative offset computation,
> the fix leads to a fair number of false negatives.  I tried
> to avoid those but couldn't come up with a clean solution
> that didn't require design changes, so I defer those to GCC
> 13.
> The diff is relative to the "cleanup" patch submitted below:
> Tested on x86_64-linux and by building Glibc and confirming
> no new warnings.
> Martin

More information about the Gcc-patches mailing list