Commit c6ba596b by Marek Polacek Committed by Marek Polacek

re PR tree-optimization/84238 (ICE tree check: expected integer_cst, have…

re PR tree-optimization/84238 (ICE tree check: expected integer_cst, have plus_expr in to_wide, at tree.h:5527)

	PR tree-optimization/84238
	* tree-ssa-strlen.c (maybe_diag_stxncpy_trunc): Verify the result of
	get_range_strlen.

	* gcc.dg/Wstringop-overflow-3.c: New test.

From-SVN: r257497
parent a4296998
2018-02-08 Marek Polacek <polacek@redhat.com>
PR tree-optimization/84238
* tree-ssa-strlen.c (maybe_diag_stxncpy_trunc): Verify the result of
get_range_strlen.
2018-02-08 Richard Sandiford <richard.sandiford@linaro.org> 2018-02-08 Richard Sandiford <richard.sandiford@linaro.org>
PR tree-optimization/84265 PR tree-optimization/84265
......
2018-02-08 Marek Polacek <polacek@redhat.com>
PR tree-optimization/84238
* gcc.dg/Wstringop-overflow-3.c: New test.
2018-02-08 Nathan Sidwell <nathan@acm.org> 2018-02-08 Nathan Sidwell <nathan@acm.org>
* g++.dg/cpp0x/initlist93.C: Adjust diagnostic. * g++.dg/cpp0x/initlist93.C: Adjust diagnostic.
......
/* PR tree-optimization/84238 */
/* { dg-do compile } */
/* { dg-options "-O2" } */
char a[1];
int b;
char *strncpy (char *, char *, __SIZE_TYPE__);
void
c ()
{
char d[b];
strncpy (a, &d[3], 3); /* { dg-warning "writing 3 bytes into a region of size 1" } */
}
...@@ -1899,7 +1899,10 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt) ...@@ -1899,7 +1899,10 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt)
{ {
tree range[2]; tree range[2];
get_range_strlen (src, range); get_range_strlen (src, range);
if (range[0]) if (range[0] != NULL_TREE
&& TREE_CODE (range[0]) == INTEGER_CST
&& range[1] != NULL_TREE
&& TREE_CODE (range[1]) == INTEGER_CST)
{ {
lenrange[0] = wi::to_wide (range[0], prec); lenrange[0] = wi::to_wide (range[0], prec);
lenrange[1] = wi::to_wide (range[1], prec); lenrange[1] = wi::to_wide (range[1], prec);
......
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