diff options
author | Richard Biener <rguenther@suse.de> | 2015-09-16 07:25:15 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2015-09-16 07:25:15 +0000 |
commit | 87261d26850e695a2e68f1e7b6115001ee67299e (patch) | |
tree | 204dfe94f503659d5aa968fbd02e9017d2abdf78 /gcc/fold-const.c | |
parent | fcb87c50b00e203aa3ef586915edd305429d3868 (diff) | |
download | gcc-87261d26850e695a2e68f1e7b6115001ee67299e.zip gcc-87261d26850e695a2e68f1e7b6115001ee67299e.tar.gz gcc-87261d26850e695a2e68f1e7b6115001ee67299e.tar.bz2 |
re PR middle-end/67442 (GCC 5.2.0 on x86_64 creates invalid address on specific array index calculation through pointer)
2015-09-16 Richard Biener <rguenther@suse.de>
PR middle-end/67442
* fold-const.c (extract_muldiv_1): Properly extend multiplication
result before builting a tree via wide_int_to_tree.
* gcc.dg/torture/pr67442.c: New testcase.
From-SVN: r227818
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index e9366e2..fd1c87e 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -6166,8 +6166,12 @@ extract_muldiv_1 (tree t, tree c, enum tree_code code, tree wide_type, && ((sign == UNSIGNED && tcode != MULT_EXPR) || sign == SIGNED)) overflow_p = true; if (!overflow_p) - return fold_build2 (tcode, ctype, fold_convert (ctype, op0), - wide_int_to_tree (ctype, mul)); + { + mul = wide_int::from (mul, TYPE_PRECISION (ctype), + TYPE_SIGN (TREE_TYPE (op1))); + return fold_build2 (tcode, ctype, fold_convert (ctype, op0), + wide_int_to_tree (ctype, mul)); + } } /* If these operations "cancel" each other, we have the main |