i686-pc-linux-gnu optimizer bug

Thomas R. Truscott trt@cs.duke.edu
Fri Apr 14 09:14:00 GMT 2000


GNU C version 2.96 20000410 (experimental) (i686-pc-linux-gnu)
mis-optimizes the "subr" routine below.
(So did 20000110, sorry for not reporting this earlier.)
With "gcc -O0" the value of "to" is the correct value 1,
with "gcc -O" the value of "to" is  the incorrect value -1.

Tom Truscott
===========

void
subr (char *src, char *dst)
{
  *dst = !!(*src & 0x80);
}

int
main()
{
  char from, to;

  from = (char)0x80;
  subr (&from, &to);
  if (to != 1)
    abort ();
  return 0;
}


More information about the Gcc-bugs mailing list