Commit 8ebc39d8 by Richard Guenther Committed by Richard Biener

re PR middle-end/36227 (POINTER_PLUS folding introduces undefined overflow)

2008-05-13  Richard Guenther  <rguenther@suse.de>

	PR middle-end/36227
	* fold-const.c (fold_sign_changed_comparison): Do not allow
	changes in pointer-ness.

	* gcc.dg/pr36227.c: New testcase.

From-SVN: r135260
parent f80cddcb
2008-05-13 Richard Guenther <rguenther@suse.de>
PR middle-end/36227
* fold-const.c (fold_sign_changed_comparison): Do not allow
changes in pointer-ness.
2008-05-12 Kaz Kojima <kkojima@gcc.gnu.org>
PR target/24713
......
......@@ -6831,7 +6831,8 @@ fold_sign_changed_comparison (enum tree_code code, tree type,
&& TREE_TYPE (TREE_OPERAND (arg1, 0)) == inner_type))
return NULL_TREE;
if (TYPE_UNSIGNED (inner_type) != TYPE_UNSIGNED (outer_type)
if ((TYPE_UNSIGNED (inner_type) != TYPE_UNSIGNED (outer_type)
|| POINTER_TYPE_P (inner_type) != POINTER_TYPE_P (outer_type))
&& code != NE_EXPR
&& code != EQ_EXPR)
return NULL_TREE;
......
2008-05-13 Richard Guenther <rguenther@suse.de>
PR middle-end/36227
* gcc.dg/pr36227.c: New testcase.
2008-05-13 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/discr7.adb: New test
/* { dg-do compile } */
/* { dg-options "-O2 -Wstrict-overflow=3" } */
volatile unsigned long *
sat_add(volatile unsigned long *ptr, unsigned long i, volatile unsigned long *end)
{
if ((unsigned long)ptr + i * sizeof(*ptr) > (unsigned long)ptr) /* { dg-bogus "pointer wraparound" } */
return ptr + i;
else
return end;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment