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]

i686-pc-linux-gnu optimizer bug


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;
}

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