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: C++ PATCH: 14035


Mark Mitchell <mark@codesourcery.com> writes:

> This patch fixes PR c++/14035.  This PR was opened because of a cast
> where we generated wrong-code for a C-style cast.  In particular, we
> generated a copy constructor call instead of a derived-to-base
> conversion.

This cause libjava to no longer build on ia64-linux:

../../../libjava/java/lang/natClass.cc: In function `void _Jv_LayoutVTableMethods(java::lang::Class*)':
../../../libjava/java/lang/natClass.cc:1823: error: cast from 'java::lang::Class*' to 'int' loses precision
../../../libjava/java/lang/natClass.cc:1831: error: cast from 'java::lang::Class*' to 'int' loses precision
../../../libjava/java/lang/natClassLoader.cc: In function `void _Jv_PrepareCompiledClass(java::lang::Class*)':
../../../libjava/java/lang/natClassLoader.cc:134: error: cast from 'java::lang::Class*' to 'int' loses precision
../../../libjava/java/lang/natClassLoader.cc:139: error: cast from 'java::lang::Class*' to 'int' loses precision

The casts to int should probably be changed to casts to uaddr.  I'm
testing this patch now:

2004-10-20  Andreas Schwab  <schwab@suse.de>

	* java/lang/natClass.cc (_Jv_LayoutVTableMethods): Cast pointers
	to uaddr, not int.
	* java/lang/natClassLoader.cc (_Jv_PrepareCompiledClass):
	Likewise.

--- libjava/java/lang/natClass.cc.~1.81.~	2004-08-12 18:21:25.000000000 +0200
+++ libjava/java/lang/natClass.cc	2004-10-20 14:52:14.527456311 +0200
@@ -1820,7 +1820,7 @@ _Jv_LayoutVTableMethods (jclass klass)
     {
       if (klass->state < JV_STATE_LINKED)
 	{
-	  _Jv_Utf8Const *name = klass->constants.data[(int)superclass].utf8;
+	  _Jv_Utf8Const *name = klass->constants.data[(uaddr)superclass].utf8;
 	  superclass = _Jv_FindClass (name, klass->loader);
 	  if (! superclass)
 	    {
@@ -1828,7 +1828,7 @@ _Jv_LayoutVTableMethods (jclass klass)
 	    }
 	}
       else
-	superclass = klass->constants.data[(int)superclass].clazz;
+	superclass = klass->constants.data[(uaddr)superclass].clazz;
     }
 
   if (superclass != NULL && superclass->vtable_method_count == -1)
--- libjava/java/lang/natClassLoader.cc.~1.69.~	2004-08-24 10:59:10.000000000 +0200
+++ libjava/java/lang/natClassLoader.cc	2004-10-20 14:23:01.378371202 +0200
@@ -131,12 +131,12 @@ _Jv_PrepareCompiledClass (jclass klass)
   // If superclass looks like a constant pool entry,
   // resolve it now.
   if ((uaddr) klass->superclass < pool->size)
-    klass->superclass = pool->data[(int) klass->superclass].clazz;
+    klass->superclass = pool->data[(uaddr) klass->superclass].clazz;
 
   // Likewise for interfaces.
   for (int i = 0; i < klass->interface_count; i++)
     if ((uaddr) klass->interfaces[i] < pool->size)
-      klass->interfaces[i] = pool->data[(int) klass->interfaces[i]].clazz;
+      klass->interfaces[i] = pool->data[(uaddr) klass->interfaces[i]].clazz;
 
   // Resolve the remaining constant pool entries.
   for (int index = 1; index < pool->size; ++index)

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


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