The following code should work on not throw a NPE or any other kind of exception (or abort): public class t { public static void main(String[] a) { int i = -1; int j = (0x80000000); int k = j/i; // int k1 = j/i; System.out.println("k = "+k); } }
Using -fuse-divide-subroutine makes this work correctly. -- Summary: 0x80000000/-1 is wrong Product: gcc Version: 4.1.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P2 Component: java AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pinskia at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu dot org GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22166