This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][RFC] Fix PR30364, reassociation not allowed for undefined overflow
- From: Rask Ingemann Lambertsen <rask at sygehus dot dk>
- To: Richard Guenther <rguenther at suse dot de>
- Cc: Ian Lance Taylor <iant at google dot com>, gcc-patches at gcc dot gnu dot org
- Date: Fri, 22 Jun 2007 19:32:14 +0200
- Subject: Re: [PATCH][RFC] Fix PR30364, reassociation not allowed for undefined overflow
- References: <Pine.LNX.4.64.0702221058390.18923@zhemvz.fhfr.qr> <m3irdu89tn.fsf@localhost.localdomain> <Pine.LNX.4.64.0702242256150.18923@zhemvz.fhfr.qr>
On Sat, Feb 24, 2007 at 10:58:41PM +0100, Richard Guenther wrote:
>
> 2007-02-21 Richard Guenther <rguenther@suse.de>
>
> PR middle-end/30364
> * fold-const.c (fold_binary): Do not associate expressions
> with more than one variable for integer types that do not wrap.
>
> * gcc.dg/torture/pr30364-1.c: New testcase.
> * gcc.dg/torture/pr30364-2.c: Likewise.
> * gcc.dg/torture/pr30364-3.c: Likewise.
>
> Index: testsuite/gcc.dg/torture/pr30364-1.c
> ===================================================================
> *** testsuite/gcc.dg/torture/pr30364-1.c (revision 0)
> --- testsuite/gcc.dg/torture/pr30364-1.c (revision 0)
> ***************
> *** 0 ****
> --- 1,19 ----
> + /* { dg-do run } */
> +
> + extern void abort (void);
> +
> + int f(int a, int b)
> + {
> + if (a > 0x7FFFFFF0) return 0;
> + if (b > 0x7FFFFFF0) return 0;
> +
> + int c = (a - 20) + (b - 20);
> + return c > 0x7FFFFFF0;
> + }
> +
> + int main()
> + {
> + if (f (0x7FFFFFF0, 41) != 1)
> + abort ();
> + return 0;
> + }
1) This tests nothing on hosts where int is 64 bits.
2) This will always fail on hosts where int is 16 bits.
Likewise for the other two tests. Examples of failures on 16-bit hosts are
in the gcc-testresult archives.
http://gcc.gnu.org/cgi-bin/search.cgi?form=extended&m=all&q=pr30364&ul=/ml/gcc-testresults/2007-03/%25&wm=wrd&s=DRP
--
Rask Ingemann Lambertsen