From: Bernd Edlinger Date: Wed, 22 Aug 2018 23:43:44 +0000 (+0000) Subject: tree-ssa-dse.c (compute_trims): Avoid folding away undefined behaviour. X-Git-Tag: basepoints/gcc-10~4584 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=36d2d101fa9d21189195cce1e90b955096a79779;p=thirdparty%2Fgcc.git tree-ssa-dse.c (compute_trims): Avoid folding away undefined behaviour. * tree-ssa-dse.c (compute_trims): Avoid folding away undefined behaviour. From-SVN: r263793 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 606fb5f6db5a..f362c36962be 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-08-22 Bernd Edlinger + + * tree-ssa-dse.c (compute_trims): Avoid folding away undefined + behaviour. + 2018-08-22 Martin Sebor PR middle-end/87052 diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c index 4cb8c0f83aca..016aa6cc97c7 100644 --- a/gcc/tree-ssa-dse.c +++ b/gcc/tree-ssa-dse.c @@ -248,6 +248,13 @@ compute_trims (ao_ref *ref, sbitmap live, int *trim_head, int *trim_tail, residual handling in mem* and str* functions is usually reasonably efficient. */ *trim_tail = last_orig - last_live; + + /* But don't trim away out of bounds accesses, as this defeats + proper warnings. */ + if (*trim_tail + && compare_tree_int (TYPE_SIZE_UNIT (TREE_TYPE (ref->base)), + last_orig) <= 0) + *trim_tail = 0; } else *trim_tail = 0;