[Bug c++/30252] [4.2 regression] miscompilation of sigc++-2.0 based code with -fstrict-aliasing
rguenth at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Mon Jun 4 15:45:00 GMT 2007
------- Comment #29 from rguenth at gcc dot gnu dot org 2007-06-04 15:45 -------
We can make it safe if we only really handle + in pointer arithmetic. Like
with
@@ -3258,7 +3255,7 @@ handle_ptr_arith (VEC (ce_s, heap) *lhsc
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) != PLUS_EXPR
&& TREE_CODE (expr) != MINUS_EXPR)
@@ -3269,9 +3266,12 @@ handle_ptr_arith (VEC (ce_s, heap) *lhsc
get_constraint_for (op0, &temp);
if (POINTER_TYPE_P (TREE_TYPE (op0))
- && TREE_CODE (op1) == INTEGER_CST
+ && host_integerp (op1, 1)
&& TREE_CODE (expr) == PLUS_EXPR)
{
+ if ((TREE_INT_CST_LOW (op1) * BITS_PER_UNIT) / BITS_PER_UNIT
+ != TREE_INT_CST_LOW (op1))
+ return false;
rhsoffset = TREE_INT_CST_LOW (op1) * BITS_PER_UNIT;
}
else
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30252
More information about the Gcc-bugs
mailing list