re PR middle-end/30338 (infinite loop in maybe_canonicalize_comparison)

2006-12-31  Richard Guenther  <rguenther@suse.de>

	PR middle-end/30338
	* fold-const.c (fold_binary): Fix type-mismatch in folding
	of -1 - A to ~A.

	* gcc.c-torture/compile/pr30338.c: New testcase.

From-SVN: r120297
This commit is contained in:
Richard Guenther 2006-12-31 14:01:19 +00:00 committed by Richard Biener
parent 20a037d5f5
commit 72ff1a9609
4 changed files with 26 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2006-12-31 Richard Guenther <rguenther@suse.de>
PR middle-end/30338
* fold-const.c (fold_binary): Fix type-mismatch in folding
of -1 - A to ~A.
2006-12-30 Kazu Hirata <kazu@codesourcery.com>
* tree-inline.c: Fix a comment typo.

View File

@ -9009,7 +9009,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
/* Convert -1 - A to ~A. */
if (INTEGRAL_TYPE_P (type)
&& integer_all_onesp (arg0))
return fold_build1 (BIT_NOT_EXPR, type, arg1);
return fold_build1 (BIT_NOT_EXPR, type, op1);
if (! FLOAT_TYPE_P (type))
{

View File

@ -1,3 +1,8 @@
2006-12-31 Richard Guenther <rguenther@suse.de>
PR middle-end/30338
* gcc.c-torture/compile/pr30338.c: New testcase.
2006-12-31 Paul Thomas <pault@gcc.gnu.org>
PR fortran/27900

View File

@ -0,0 +1,14 @@
/* We used to do folding with mismatched types which caused us to
infinitely loop in comparison foldings. */
extern char *grub_scratch_mem;
int testload_func (char *arg, int flags)
{
int i;
for (i = 0; i < 0x10ac0; i++)
if (*((unsigned char *) ((0x200000 + i + (int) grub_scratch_mem)))
!= *((unsigned char *) ((0x300000 + i + (int) grub_scratch_mem))))
return 0;
return 1;
}