sprintf warning on overlapping output
Jeff Law
law@redhat.com
Mon Sep 26 15:02:00 GMT 2016
On 09/25/2016 03:46 AM, Bernd Edlinger wrote:
> Hi Martin,
>
> in the past I have seen (and fixed) code like
>
> sprintf(buf, "%s %d", buf, x);
>
> that may possibly work by chance, but usually
> produces undefined results.
>
> Do you see a way to enhance the warning for cases
> where the output buffer overlaps an input buffer?
ISTM you really need strong PTA analysis here to nail down the pointers
to a single object, then you can query their ranges and look for overlap.
Jeff
More information about the Gcc
mailing list