Re: Silent gcc 4.2.0 loop optimization bug with -O2

From: Alexander Kabaev <kabaev_at_gmail.com>
Date: Mon, 25 Jun 2007 11:22:18 -0400
On 6/25/07, Andrey Chernov <ache_at_nagual.pp.ru> wrote:
> On Mon, Jun 25, 2007 at 09:59:21AM -0400, Alexander Kabaev wrote:
> >  It is trivial to extract a sample for miscompiltations. Just use
> >  -save-temps and cut down the code until you have a simple case. If you
> >  cannot be bothered to do that, nobody else would either,
>
> Well... Is this small enough?
>
> cc -O2 a.c
> ./a.out
> cc -O a.c
> ./a.out
> ------------------------------------------------------------------
> #include <stdio.h>
>
> const char *szElem[4];
>
> void main()
> {
>  float power1[80], total2;
>  int i, j;
>  char sz[80];
>
>  for (i = 1; i <= 12; i++) {
>    if (i <= 4) {
>      sprintf(sz, "  -%9.7s:", szElem[i-1]);
>      for (j = 1; j < 12; j += 4)
>        total2 += power1[i-1+j];
>    } else if (i == 6) {
>    } else if (i >= 7 && i <= 9) {
>      printf("MUST BE HERE!!! %d\n", i);
>    }
>  }
> }
> -------------------------------------------------------------------
>
> --
> http://ache.pp.ru/
>
This one is almost perfect.

-- 
Alexander Kabaev
Received on Mon Jun 25 2007 - 13:22:20 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:13 UTC