This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/54924] Warn for std::string constructor with wrong size


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

--- Comment #8 from Martin Sebor <msebor at gcc dot gnu.org> ---
Author: msebor
Date: Thu May  4 23:50:21 2017
New Revision: 247622

URL: https://gcc.gnu.org/viewcvs?rev=247622&root=gcc&view=rev
Log:
PR libstdc++/54924 - Warn for std::string constructor with wrong size
PR middle-end/79234 - warn on past the end reads by library functions

gcc/ChangeLog:

        PR middle-end/79234
        * builtins.c (check_sizes): Adjust to handle reading past the end.
        Avoid printing excessive upper bound of ranges.  Use %E to print
        tree nodes instead of converting them to %wu.
        (expand_builtin_memchr): New function.
        (compute_dest_size): Rename...
        (compute_objsize): ...to this.
        (expand_builtin_memcpy): Adjust.
        (expand_builtin_mempcpy): Adjust.
        (expand_builtin_strcat): Adjust.
        (expand_builtin_strcpy): Adjust.
        (check_strncat_sizes): Adjust.
        (expand_builtin_strncat): Adjust.
        (expand_builtin_strncpy): Adjust and simplify.
        (expand_builtin_memset): Adjust.
        (expand_builtin_bzero): Adjust.
        (expand_builtin_memcmp): Adjust.
        (expand_builtin): Handle memcmp.
        (maybe_emit_chk_warning): Check strncat just once.

gcc/testsuite/ChangeLog:

        PR middle-end/79234
        * gcc.dg/builtin-stringop-chk-8.c: New test.
        * gcc.dg/builtin-stringop-chk-1.c: Adjust.
        * gcc.dg/builtin-stringop-chk-4.c: Same.
        * gcc.dg/builtin-strncat-chk-1.c: Same.
        * g++.dg/ext/strncpy-chk1.C: Same.
        * g++.dg/torture/Wsizeof-pointer-memaccess1.C: Same.
        * gcc.dg/out-of-bounds-1.c: Same.
        * gcc.dg/pr78138.c: Same.
        * gcc.dg/torture/Wsizeof-pointer-memaccess1.c: Same.
        * gfortran.dg/mvbits_7.f90: Same.


Added:
    trunk/gcc/testsuite/gcc.dg/builtin-stringop-chk-8.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/g++.dg/torture/Wsizeof-pointer-memaccess1.C
    trunk/gcc/testsuite/gcc.dg/builtin-stringop-chk-1.c
    trunk/gcc/testsuite/gcc.dg/builtin-stringop-chk-4.c
    trunk/gcc/testsuite/gcc.dg/builtin-strncat-chk-1.c
    trunk/gcc/testsuite/gcc.dg/out-of-bounds-1.c
    trunk/gcc/testsuite/gcc.dg/pr78138.c
    trunk/gcc/testsuite/gcc.dg/torture/Wsizeof-pointer-memaccess1.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-1.c
    trunk/gcc/testsuite/gfortran.dg/mvbits_7.f90

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]