diff options
author | Richard Biener <rguenth@gcc.gnu.org> | 2007-06-19 12:57:58 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2007-06-19 12:57:58 +0000 |
commit | 9bf448b9057dee370741ca48edfc9bec954894a6 (patch) | |
tree | bd94d5dc228225eeb3ef8f7672769335206713d3 /gcc/tree-ssa-structalias.c | |
parent | 258d0b9b9e7ca27b5e7e3a2dbb1488a9f4e13bfd (diff) | |
download | gcc-9bf448b9057dee370741ca48edfc9bec954894a6.zip gcc-9bf448b9057dee370741ca48edfc9bec954894a6.tar.gz gcc-9bf448b9057dee370741ca48edfc9bec954894a6.tar.bz2 |
tree-ssa-structalias.c (handle_ptr_arith): Make sure to only handle positive offsets that fit in a HOST_WIDE_INT.
2007-06-19 Richard Guenther <rguenther@suse.de>
* tree-ssa-structalias.c (handle_ptr_arith): Make sure to
only handle positive offsets that fit in a HOST_WIDE_INT.
* g++.dg/torture/pr30252.C: New testcase.
From-SVN: r125849
Diffstat (limited to 'gcc/tree-ssa-structalias.c')
-rw-r--r-- | gcc/tree-ssa-structalias.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 2b69728..663dff0 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -3291,7 +3291,7 @@ handle_ptr_arith (VEC (ce_s, heap) *lhsc, tree expr) unsigned int i = 0; unsigned int j = 0; VEC (ce_s, heap) *temp = NULL; - unsigned int rhsoffset = 0; + unsigned HOST_WIDE_INT rhsoffset = 0; if (TREE_CODE (expr) != POINTER_PLUS_EXPR) return false; @@ -3302,8 +3302,15 @@ handle_ptr_arith (VEC (ce_s, heap) *lhsc, tree expr) get_constraint_for (op0, &temp); - if (TREE_CODE (op1) == INTEGER_CST) - rhsoffset = TREE_INT_CST_LOW (op1) * BITS_PER_UNIT; + /* We can only handle positive offsets that do not overflow + if we multiply it by BITS_PER_UNIT. */ + if (host_integerp (op1, 1)) + { + rhsoffset = TREE_INT_CST_LOW (op1) * BITS_PER_UNIT; + + if (rhsoffset / BITS_PER_UNIT != TREE_INT_CST_LOW (op1)) + return false; + } for (i = 0; VEC_iterate (ce_s, lhsc, i, c); i++) for (j = 0; VEC_iterate (ce_s, temp, j, c2); j++) |