[Bug tree-optimization/82646] bogus -Wstringop-overflow with -D_FORTIFY_SOURCE=2 on strncpy with range to a member array

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Dec 6 17:59:00 GMT 2017


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

--- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> ---
Author: msebor
Date: Wed Dec  6 17:59:01 2017
New Revision: 255448

URL: https://gcc.gnu.org/viewcvs?rev=255448&root=gcc&view=rev
Log:
PR tree-optimization/82646 - bogus -Wstringop-overflow with -D_FORTIFY_SOURCE=2
on strncpy with range to a member array

gcc/ChangeLog:

        PR tree-optimization/82646
        * builtins.c (maybe_emit_chk_warning): Use size as the bound for
        strncpy, not maxlen.

gcc/testsuite/ChangeLog:

        PR tree-optimization/82646
        * gcc.dg/builtin-stringop-chk-1.c: Adjust.
        * gcc.dg/builtin-stringop-chk-9.c: New test.
        * g++.dg/ext/strncpy-chk1.C: Adjust.


Added:
    trunk/gcc/testsuite/gcc.dg/builtin-stringop-chk-9.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/builtins.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/ext/strncpy-chk1.C
    trunk/gcc/testsuite/gcc.dg/builtin-stringop-chk-1.c


More information about the Gcc-bugs mailing list