Bug 31842 - [4.2/4.3 Regression] r124338 causes java Divide_1 and pr6388 to fail
Summary: [4.2/4.3 Regression] r124338 causes java Divide_1 and pr6388 to fail
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: java (show other bugs)
Version: 4.2.0
: P3 blocker
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks: 31739
  Show dependency treegraph
 
Reported: 2007-05-06 05:42 UTC by David Daney
Modified: 2007-05-08 14:52 UTC (History)
8 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build: x86_64-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Patch (309 bytes, patch)
2007-05-07 19:03 UTC, Ian Lance Taylor
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Daney 2007-05-06 05:42:29 UTC
Examining testresults:
 http://gcc.gnu.org/ml/gcc-testresults/2007-05/msg00045.html
and
 http://gcc.gnu.org/ml/gcc-testresults/2007-05/msg00102.html

Leads us to the conclusion the the patch r124338 causes regressions in the java testsuite for Divide_1 and pr6388 on the 4.2 branch.  The corresponding trunk patch seems to break the trunk in a similar manner.

I am bootstrapping before and after the patch to prove to myself that it is culpable
Comment 1 David Daney 2007-05-07 04:23:59 UTC
I just finished bootstrapping and testing r124337 and r124338 on x86_64-pc-linux-gnu (FC6). Not surprisingly, this verifies that r124338 causes the regression.
Comment 2 Ian Lance Taylor 2007-05-07 19:03:06 UTC
Created attachment 13523 [details]
Patch

The bug is that some C++ code in libjava assumes that signed overflow is defined.  This is not true for C++.

I'm testing this patch now on 4.2 branch.
Comment 3 Andrew Haley 2007-05-07 19:18:45 UTC
Thanks for the patch.

I could have sworn that we were compiling libgcj's C++ code with -fwrapv in order give CNI code effectively the same integer overflow behaviour as Java.  I just checked, and we aren't.  We really should be -- and I presume that would also fix this bug -- but it's perhaps safer to apply this special-case patch.
Comment 4 David Daney 2007-05-07 20:14:03 UTC
(In reply to comment #3)
> Thanks for the patch.
> 
> I could have sworn that we were compiling libgcj's C++ code with -fwrapv in
> order give CNI code effectively the same integer overflow behaviour as Java.  I
> just checked, and we aren't.  We really should be -- and I presume that would
> also fix this bug -- but it's perhaps safer to apply this special-case patch.

There are pluses and minuses to adding -fwrapv.

On the plus side, this bug would not have been uncovered (arguably it would not even be a bug).

On the minus side CNI code ceases to be C++, but has special non-standard wrapping semantics.

Comment 5 ian@gcc.gnu.org 2007-05-08 01:29:46 UTC
Subject: Bug 31842

Author: ian
Date: Tue May  8 00:29:43 2007
New Revision: 124530

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=124530
Log:
	PR java/31842
	* java/lang/natString.cc (_Jv_FormatInt): Avoid undefined signed
	overflow.

Modified:
    trunk/libjava/ChangeLog
    trunk/libjava/java/lang/natString.cc

Comment 6 ian@gcc.gnu.org 2007-05-08 01:30:30 UTC
Subject: Bug 31842

Author: ian
Date: Tue May  8 00:30:27 2007
New Revision: 124531

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=124531
Log:
	PR java/31842
	* java/lang/natString.cc (_Jv_FormatInt): Avoid undefined signed
	overflow.

Modified:
    branches/gcc-4_2-branch/libjava/ChangeLog
    branches/gcc-4_2-branch/libjava/java/lang/natString.cc

Comment 7 Ian Lance Taylor 2007-05-08 01:32:00 UTC
Fixed on mainline and 4.2 branch.
Comment 8 Richard Biener 2007-09-09 20:13:08 UTC
Subject: Bug 31842

Author: rguenth
Date: Sun Sep  9 20:12:56 2007
New Revision: 128306

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128306
Log:
2007-09-09  Richard Guenther  <rguenther@suse.de>

	Backport from mainline:
	2007-05-07  Ian Lance Taylor  <iant@google.com>

	PR java/31842
	* java/lang/natString.cc (_Jv_FormatInt): Avoid undefined signed
	overflow.

Modified:
    branches/gcc-4_1-branch/libjava/ChangeLog
    branches/gcc-4_1-branch/libjava/java/lang/natString.cc