This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Widespread arithmetic optimisation bug



  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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]