[Bug java/22166] 0x80000000/-1 is wrong in java

rmathew at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Tue Aug 30 09:22:00 GMT 2005


------- Additional Comments From rmathew at gcc dot gnu dot org  2005-08-30 09:13 -------
Actually, this looks like a more generic problem, not limited to Java.

Witness:
----------------------------------- 8< -----------------------------------
~/src/tmp/PR22166 > cat x.c
#include <stdio.h>
int main( void)
{
  int i = 0x80000000;
  int j = -1;
  printf( "%u: %d\n", sizeof(int), i/j);
  return 0;
}
~/src/tmp/PR22166 > mygcc --version
xgcc (GCC) 4.1.0 20050830 (experimental)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

~/src/tmp/PR22166 > mygcc x.c
~/src/tmp/PR22166 > ./a.out
Floating point exception
~/src/tmp/PR22166 > mygcc -O1 x.c
~/src/tmp/PR22166 > ./a.out
4: -2147483648
~/src/tmp/PR22166 >
----------------------------------- 8< -----------------------------------


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22166



More information about the Gcc-bugs mailing list