From: Jakub Jelinek Date: Thu, 15 Feb 2018 11:18:47 +0000 (+0100) Subject: re PR tree-optimization/84383 (ICE in maybe_diag_stxncpy_trunc) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=44e60df333a5fa63428a12887d9c8b5471e1a01b;p=gcc.git re PR tree-optimization/84383 (ICE in maybe_diag_stxncpy_trunc) PR tree-optimization/84383 * tree-ssa-strlen.c (maybe_diag_stxncpy_trunc): Don't look at dstoff nor call operand_equal_p if dstbase is NULL. * gcc.c-torture/compile/pr84383.c: New test. From-SVN: r257684 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 05b77100138..2768ada22b7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2018-02-15 Jakub Jelinek + PR tree-optimization/84383 + * tree-ssa-strlen.c (maybe_diag_stxncpy_trunc): Don't look at + dstoff nor call operand_equal_p if dstbase is NULL. + PR tree-optimization/84334 * match.pd ((A +- CST1) +- CST2 -> A + CST3): If A is also a CONSTANT_CLASS_P, punt. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2ac6e7b0dfa..c9f53d80b68 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2018-02-15 Jakub Jelinek + PR tree-optimization/84383 + * gcc.c-torture/compile/pr84383.c: New test. + PR tree-optimization/84334 * gcc.dg/pr84334.c: New test. diff --git a/gcc/testsuite/gcc.c-torture/compile/pr84383.c b/gcc/testsuite/gcc.c-torture/compile/pr84383.c new file mode 100644 index 00000000000..b46f7819b74 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr84383.c @@ -0,0 +1,14 @@ +/* PR tree-optimization/84383 */ + +struct S { char *s; }; +void bar (struct S *); + +void +foo (int a, char *b) +{ + struct S c[4]; + bar (c); + __builtin_strncpy (c[a].s, b, 32); + c[a].s[31] = '\0'; + bar (c); +} diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index 94ed2bedc03..09ffa154439 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -1878,6 +1878,7 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt) poly_int64 lhsoff; tree lhsbase = get_addr_base_and_unit_offset (lhs, &lhsoff); if (lhsbase + && dstbase && known_eq (dstoff, lhsoff) && operand_equal_p (dstbase, lhsbase, 0)) return false;