public inbox for java-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug java/22166] New: 0x80000000/-1 is wrong
@ 2005-06-23 16:06 pinskia at gcc dot gnu dot org
  2005-06-24  9:45 ` [Bug java/22166] " rmathew at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-23 16:06 UTC (permalink / raw)
  To: java-prs

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug java/22166] 0x80000000/-1 is wrong
  2005-06-23 16:06 [Bug java/22166] New: 0x80000000/-1 is wrong pinskia at gcc dot gnu dot org
@ 2005-06-24  9:45 ` rmathew at gcc dot gnu dot org
  2005-07-01 19:12 ` [Bug java/22166] 0x80000000/-1 is wrong in java pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rmathew at gcc dot gnu dot org @ 2005-06-24  9:45 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From rmathew at gcc dot gnu dot org  2005-06-24 09:44 -------
This is most likely the same as PR22084 (see the testcase
$GCC_SRC_DIR/libjava/testsuite/libjava.lang/Divide_1.java).

-- 


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug java/22166] 0x80000000/-1 is wrong in java
  2005-06-23 16:06 [Bug java/22166] New: 0x80000000/-1 is wrong pinskia at gcc dot gnu dot org
  2005-06-24  9:45 ` [Bug java/22166] " rmathew at gcc dot gnu dot org
@ 2005-07-01 19:12 ` pinskia at gcc dot gnu dot org
  2005-08-05  4:09 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-01 19:12 UTC (permalink / raw)
  To: java-prs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|0x80000000/-1 is wrong      |0x80000000/-1 is wrong in
                   |                            |java


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug java/22166] 0x80000000/-1 is wrong in java
  2005-06-23 16:06 [Bug java/22166] New: 0x80000000/-1 is wrong pinskia at gcc dot gnu dot org
  2005-06-24  9:45 ` [Bug java/22166] " rmathew at gcc dot gnu dot org
  2005-07-01 19:12 ` [Bug java/22166] 0x80000000/-1 is wrong in java pinskia at gcc dot gnu dot org
@ 2005-08-05  4:09 ` pinskia at gcc dot gnu dot org
  2005-08-30  7:33 ` rmathew at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-05  4:09 UTC (permalink / raw)
  To: java-prs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-08-05 04:09:29
               date|                            |


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug java/22166] 0x80000000/-1 is wrong in java
  2005-06-23 16:06 [Bug java/22166] New: 0x80000000/-1 is wrong pinskia at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2005-08-05  4:09 ` pinskia at gcc dot gnu dot org
@ 2005-08-30  7:33 ` rmathew at gcc dot gnu dot org
  2005-08-30  9:13 ` rmathew at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rmathew at gcc dot gnu dot org @ 2005-08-30  7:33 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From rmathew at gcc dot gnu dot org  2005-08-30 07:33 -------
Still exists on mainline. At optimisation levels 1,2 and 3, this bug disappears.

Also disappears if "-fuse-divide-subroutine" is used.

Seems to have been introduced between June 14th and 15th:

  http://gcc.gnu.org/ml/gcc-testresults/2005-06/msg00864.html
  http://gcc.gnu.org/ml/gcc-testresults/2005-06/msg00932.html


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2005-08-05 04:09:29         |2005-08-30 07:33:27
               date|                            |


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug java/22166] 0x80000000/-1 is wrong in java
  2005-06-23 16:06 [Bug java/22166] New: 0x80000000/-1 is wrong pinskia at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2005-08-30  7:33 ` rmathew at gcc dot gnu dot org
@ 2005-08-30  9:13 ` rmathew at gcc dot gnu dot org
  2005-08-30 19:14 ` falk at debian dot org
  2005-09-17  3:27 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: rmathew at gcc dot gnu dot org @ 2005-08-30  9:13 UTC (permalink / raw)
  To: java-prs


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug java/22166] 0x80000000/-1 is wrong in java
  2005-06-23 16:06 [Bug java/22166] New: 0x80000000/-1 is wrong pinskia at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2005-08-30  9:13 ` rmathew at gcc dot gnu dot org
@ 2005-08-30 19:14 ` falk at debian dot org
  2005-09-17  3:27 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: falk at debian dot org @ 2005-08-30 19:14 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From falk at debian dot org  2005-08-30 19:14 -------
(In reply to comment #3)
> Actually, this looks like a more generic problem, not limited to Java.

In C, signed overflow is undefined, so any result or behavior would be
acceptable.

-- 


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug java/22166] 0x80000000/-1 is wrong in java
  2005-06-23 16:06 [Bug java/22166] New: 0x80000000/-1 is wrong pinskia at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2005-08-30 19:14 ` falk at debian dot org
@ 2005-09-17  3:27 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-17  3:27 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-09-17 03:27 -------
Fixed for 4.1.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.1.0


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-09-17  3:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-23 16:06 [Bug java/22166] New: 0x80000000/-1 is wrong pinskia at gcc dot gnu dot org
2005-06-24  9:45 ` [Bug java/22166] " rmathew at gcc dot gnu dot org
2005-07-01 19:12 ` [Bug java/22166] 0x80000000/-1 is wrong in java pinskia at gcc dot gnu dot org
2005-08-05  4:09 ` pinskia at gcc dot gnu dot org
2005-08-30  7:33 ` rmathew at gcc dot gnu dot org
2005-08-30  9:13 ` rmathew at gcc dot gnu dot org
2005-08-30 19:14 ` falk at debian dot org
2005-09-17  3:27 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).