Commit 7d4ae1fb by Bernd Edlinger Committed by Bernd Edlinger

re PR middle-end/86121 (missing -Wstringop-overflow on strcpy followed by strcat)

2018-08-21  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR middle-end/86121
        * tree-ssa-strlen.c (adjust_last_stmt): Avoid folding away undefined
        behaviour.

testsuite:
2018-08-21  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR middle-end/86121
        * gcc.dg/Wstringop-overflow-6.c: Remove xfail.

From-SVN: r263693
parent eae016fc
2018-08-21 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR middle-end/86121
* tree-ssa-strlen.c (adjust_last_stmt): Avoid folding away undefined
behaviour.
2018-08-21 Rasmus Villemoes <rv@rasmusvillemoes.dk>
* config/vxworks.h: Guard vxworks_asm_out_constructor and
......
2018-08-21 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR middle-end/86121
* gcc.dg/Wstringop-overflow-6.c: Remove xfail.
2018-08-21 Tom de Vries <tdevries@suse.de>
* gcc.c-torture/unsorted/dump-noaddr.x: Use -gno-record-gcc-switches
......
......@@ -25,7 +25,7 @@ void test_strcpy_strcat_1 (void)
void test_strcpy_strcat_2 (void)
{
strcpy (a2, "12"), strcat (a2, "3"); /* { dg-warning "\\\[-Wstringop-overflow=]" "bug 86121" { xfail *-*-* } } */
strcpy (a2, "12"), strcat (a2, "3"); /* { dg-warning "\\\[-Wstringop-overflow=]" } */
}
void test_strcpy_strcat_3 (void)
......
......@@ -1107,6 +1107,13 @@ adjust_last_stmt (strinfo *si, gimple *stmt, bool is_strcat)
to store the extra '\0' in that case. */
if ((tree_to_uhwi (len) & 3) == 0)
return;
/* Don't fold away an out of bounds access, as this defeats proper
warnings. */
tree dst = gimple_call_arg (last.stmt, 0);
tree size = compute_objsize (dst, 0);
if (size && tree_int_cst_lt (size, len))
return;
}
else if (TREE_CODE (len) == SSA_NAME)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment