Silent gcc 4.2.0 loop optimization bug with -O2

From: Andrey Chernov <ache_at_nagual.pp.ru>
Date: Mon, 25 Jun 2007 17:09:13 +0400
This is serious loop optimization bug with -O2.
I can't cut it down to the small sample, so here are simple steps to 
reproduce:

1) Compile/install misc/astrolog port, with or WITHOUT_X11, it does not 
matter.
(I just commit CFLAGS+=-O in its Makefile as workaround of this bug, so 
change it to CFLAGS+=-O2 to see the bug in action)

2) Run "astrolog -n -j0"
See lower right corner empty (under "Mode Power Percent")

3) Change back to CFLAGS+=-O, recompile, reinstall, run, see _filled_
lower right corner.

To the code - in the intrpret.c:ChartInfluence(), near the very end of 
the file is a basic loop like that:

for (i = 1; i <= 12; i++) {
  ...
  if (i <= 4) {
    ...
  } else if (i == 6) {
    ...
  } else if (i >= 7 && i <= 9) {
!!!!! It never goes here with -O2 !!!!!
    ...
  }
  ...
}

Note: the exact example code above DOES NOT trigger the bug, as I say I 
can't cut it down to small sample, I just provide it for hint where bug 
place is.

-- 
http://ache.pp.ru/
Received on Mon Jun 25 2007 - 11:23:35 UTC

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