This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Patch: RFC: alignment fix in resolve.cc
The appended program is enough to see the problem.
In the interpreter, "z" is 8 bytes. When compiled, it is 12 bytes.
I'm sure this is observable using -fno-assume-compiled, since you can
mix interpreted and compiled code in that mode.
I've appended the patch that fixes this. I'm checking it in on the
trunk. Tested on x86 Red Hat Linux 7.3.
I don't think there is any (supported) way to see this bug on the 3.3
branch. I'm not going to check it in there, unless someone has a
reason I should.
Tom
class x
{
short field1;
}
public class z extends x
{
short field2;
public static void main(String[] args)
{
}
}
Index: libjava/ChangeLog
from Tom Tromey <tromey at redhat dot com>
* resolve.cc (_Jv_PrepareClass): Round up class size to multiple
of alignment.
Index: libjava/resolve.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/resolve.cc,v
retrieving revision 1.34.2.2
diff -u -r1.34.2.2 resolve.cc
--- libjava/resolve.cc 3 Feb 2003 21:04:50 -0000 1.34.2.2
+++ libjava/resolve.cc 15 Apr 2003 00:04:51 -0000
@@ -512,7 +512,10 @@
}
}
- // set the instance size for the class
+ // Set the instance size for the class. Note that first we round it
+ // to the alignment required for Object; this keeps us in sync with
+ // our current ABI.
+ instance_size = ROUND (instance_size, __alignof__ (java::lang::Object));
clz->size_in_bytes = instance_size;
// allocate static memory