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]

Patch: FYI: PR java/26042


I'm checking this in on the trunk and the 4.1 branch.
This fixes PR java/26042.

What happens in this PR is that we lay out classes multiple times.  At
one point, the class One is laid out while its fields are still
reversed (I don't know why we construct the field list in reverse
order, but we do).

Then we lay out the inner class Two$Three.  The 'superclass' field of
this class gets its size set.

Later when we relayout the classes with their fields in the correct
order, the superclass field of Two$Three keeps the size that was
previously set -- but this size is wrong, because on PPC changing the
order of these fields results in different object sizes, due to
differing amounts of padding.

I don't really understand why we don't see this bug on more platforms.

The fix I'm applying works by NULLing out the size of the superclass
field when we reorder the fields and NULL the size of the type.  This
is a bit of a hack, but this field is the only one whose size can
change.

Tested on ppc linux (don't know what distro, probably RHEL) and x86 FC4.

Tom

Index: gcc/java/ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	PR java/26042:
	* parse.y (java_reorder_fields): Reset superclass field's size as
	well.

Index: libjava/ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	PR java/26042:
	* testsuite/libjava.compile/pr26042.java: New file.

Index: gcc/java/parse.y
===================================================================
--- gcc/java/parse.y	(revision 112499)
+++ gcc/java/parse.y	(working copy)
@@ -7770,6 +7770,10 @@
 	if (!DECL_NAME (TYPE_FIELDS (current_class)))
 	  {
 	    tree fields = TYPE_FIELDS (current_class);
+	    /* This works around a problem where on some platforms,
+	       the field might be given its size incorrectly.  */
+	    DECL_SIZE (fields) = NULL_TREE;
+	    DECL_SIZE_UNIT (fields) = NULL_TREE;
 	    TREE_CHAIN (fields) = nreverse (TREE_CHAIN (fields));
 	    TYPE_SIZE (current_class) = NULL_TREE;
 	  }
Index: libjava/testsuite/libjava.compile/pr26042.java
===================================================================
--- libjava/testsuite/libjava.compile/pr26042.java	(revision 0)
+++ libjava/testsuite/libjava.compile/pr26042.java	(revision 0)
@@ -0,0 +1,12 @@
+class One
+{
+    long l;    // no ICE if this is int, not long
+    int b;     // no ICE if this line is gone; type doesn't matter
+}
+
+public class pr26042
+{
+    class Three extends One { }
+    Three three () { return new Three (); }
+}
+


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