[PATCH] avoid calling memset et al. with excessively large sizes (PR 79095)

Jeff Law law@redhat.com
Tue Jan 17 15:26:00 GMT 2017


On 01/16/2017 05:06 PM, Martin Sebor wrote:
> The test case submitted in bug 79095 - [7 regression] spurious
> stringop-overflow warning shows that GCC optimizes some loops
> into calls to memset with size arguments in excess of the object
> size limit.  Since such calls will unavoidably lead to a buffer
> overflow and memory corruption the attached patch detects them
> and replaces them with a trap.  That both prevents the buffer
> overflow and eliminates the warning.
But doesn't the creation of the bogus memset signal an invalid 
transformation in the loop optimizer?  ie, if we're going to convert a 
loop into a memset, then we'd damn well better be sure the loop bounds 
are reasonable.

Jeff



More information about the Gcc-patches mailing list