Bug in GCC 2.95.2

Jeffrey A Law law@cygnus.com
Tue Dec 14 10:00:00 GMT 1999


  In message < Pine.LNX.4.10.9912141303270.9803-100000@balti.cygnus.co.uk >you wr
ite:
  > On Mon, 13 Dec 1999, Robert Ruehlmann wrote:
  > 
  > > When optimized with -O2 the following small sample program goes into an
  > > infinite loop.  Debugging with gdb shows strange behaviour like
  > > modifications of the 'size' variable.
  > > 
  > > <-- cut here -->
  > > static void bug(int size, int tries)
  > > {
  > >     int i;
  > >     int num = 0;
  > > 
  > >     while (num < size)
  > >     {
  > >         for (i = 1; i < tries; i++) num++;
  > >     }
  > > }
  > > 
  > > int main()
  > > {
  > >     bug(5, 10);
  > >     return 0;
  > > }
  > > <-- cut here -->
  > 
  > This is a bug in check_dbra_loop.  Both loops get reversed; this is OK for
  > the inner loop but not for the outer one, as we can't tell how often num
  > will be incremented (and thus we don't know whether the exit test, which is
  > an equality test against zero after reversing, will succeed).
  > 
  > There is already code in check_dbra_loop to verify that a biv that will be
  > reversed is only set once.  The patch below improves the test to also take
  > maybe_multiple into account.
  > 
  > Bernd
  > 
  > 	* loop.c (check_dbra_loop): Can't reverse a biv for which
  > 	maybe_multiple is set.
This is fine.  Please install it.

Thanks,
jeff



More information about the Gcc-bugs mailing list