This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Widespread arithmetic optimisation bug
- To: Robert Harley <Robert dot Harley at inria dot fr>
- Subject: Re: Widespread arithmetic optimisation bug
- From: Jeffrey A Law <law at hurl dot cygnus dot com>
- Date: Sat, 27 Feb 1999 01:24:48 -0700
- cc: egcs-bugs at cygnus dot com
- Reply-To: law at cygnus dot com
In message <199902261714.SAA13246@pauillac.inria.fr>you write:
> Here's a little program that reveals a bug with optimisation on.
>
> I've seen it with ints and longs, on Alpha and x86, with gcc and egcs
> releases...
>
> ---------------------------------------------------------------------------
> ---
> /* Run with:
>
> gcc -v
> gcc -O0 bug.c
> ./a.out && echo OK || echo Broken
> gcc -O1 bug.c
> ./a.out && echo OK || echo Broken
>
> */
>
> unsigned bla(unsigned b) {
> unsigned q;
>
> q = -1U/b;
> b = -q*b;
>
> return b;
> } /* end bla */
>
> int main(int argc, char *argv[]) {
> unsigned r;
>
> r = bla(-5U);
>
> return r != 5U;
> } /* end main */
I believe this bug has been fixed for the upcoming egcs-1.1.2.
Thanks,
jeff