This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

Re: [PATCH][4.1] Fix PR33142, wrong-code with VRP


On Sun, 9 Sep 2007, Richard Guenther wrote:

> On Sun, 9 Sep 2007, Andrew Pinski wrote:
> 
> > On 9/9/07, Richard Guenther <rguenther@suse.de> wrote:
> > > Probably, as the above doesn't contain an unary expression for
> > > which I changed behavior.  Can you open a PR for this please?
> > 
> > Actually libjava has undefined code in it.  It depends on signed
> > integer overflow being defined as wrapping.
> > See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31842
> > 
> > So backporting that patch should fix the issue too.
> 
> I'll take care of this.

I verified it does.  Bootstrapped and tested on x86_64-unknown-linux-gnu,
applied to the 4.1 branch.

Richard.

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.

Index: java/lang/natString.cc
===================================================================
--- java/lang/natString.cc	(revision 128300)
+++ java/lang/natString.cc	(working copy)
@@ -371,11 +371,11 @@ _Jv_FormatInt (jchar* bufend, jint num)
   if (num < 0)
     {
       isNeg = true;
-      num = -(num);
-      if (num < 0)
+      if (num != (jint) -2147483648U)
+	num = -(num);
+      else
 	{
-	  // Must be MIN_VALUE, so handle this special case.
-	  // FIXME use 'unsigned jint' for num.
+	  // Handle special case of MIN_VALUE.
 	  *--ptr = '8';
 	  num = 214748364;
 	}


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