https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78768

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=71907

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Bug 71907 points out a similar problem with buffer overflow warnings issued by
_FORTIFY_SOURCE.  That bug has been fixed and a test case for the
-Wstringop-overflow option works as expected:

$ (set -x && cat a.c && for o in -fno-lto -flto; do /build/gcc-svn/gcc/xgcc -B
/build/gcc-svn/gcc -O2 $o a.c; done)
+ cat a.c
char d[1];

int main (int argc, char *argv[])
{
  char *s = argc < 3 ? "12" : "123";

  __builtin_strcpy (d, s);
}
+ for o in -fno-lto -flto
+ /build/gcc-svn/gcc/xgcc -B /build/gcc-svn/gcc -O2 -fno-lto a.c
a.c: In function ‘main’:
a.c:7:3: warning: ‘__builtin_strcpy’ writing 3 bytes into a region of size 1
overflows the destination [-Wstringop-overflow=]
   __builtin_strcpy (d, s);
   ^~~~~~~~~~~~~~~~~~~~~~~
+ for o in -fno-lto -flto
+ /build/gcc-svn/gcc/xgcc -B /build/gcc-svn/gcc -O2 -flto a.c
a.c: In function ‘main’:
a.c:7:3: warning: ‘__builtin_strcpy’ writing 3 bytes into a region of size 1
overflows the destination [-Wstringop-overflow=]
   __builtin_strcpy (d, s);
   ^

Reply via email to