sprintf warning on overlapping output
Eric Gallager
egall@gwmail.gwu.edu
Sun Sep 25 13:28:00 GMT 2016
On 9/25/16, Bernd Edlinger <bernd@edlinger-online.de> 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?
>
>
>
> Thanks
> Bernd.
>
I was testing Prathamesh's -Wrestrict patch, and it caught a few cases
like that:
https://gcc.gnu.org/ml/gcc-patches/2016-09/msg00027.html
Eric
More information about the Gcc
mailing list