This is the mail archive of the gcc-bugs@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]

middle-end/6608: code generation bug when building libgcj



>Number:         6608
>Category:       middle-end
>Synopsis:       code generation bug when building libgcj
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed May 08 11:36:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Tom Tromey
>Release:        gcj (GCC) 3.2 20020505 (experimental)
>Organization:
>Environment:

>Description:
I've found what I believe to be a code generation bug on the current
cvs trunk.

The bug apparently occurs when compiling the libgcj class
java.lang.reflect.Modifier, in method isPublic().

The test case below, from the libgcj test suite, demonstrates the bug.

It prints this:

    public private void KeepInline.example()
    public static void KeepInline.main(java.lang.String[])

Note the "public private".

Here is what I see if I go to Modifier.isPublic in gdb:

    java.lang.reflect.Modifier.isPublic(int) (mod=2)
	at ../../../gcc/libjava/java/lang/reflect/Modifier.java:227
    (gdb) p mod
    $5 = 2
    (gdb) fini
    Run till exit from #0  java.lang.reflect.Modifier.isPublic(int) (mod=2)
	at ../../../gcc/libjava/java/lang/reflect/Modifier.java:227
    0x40359dc1 in java.lang.reflect.Modifier.toString(int, java.lang.StringBuffer)
	(mod=2, r=@80b5be0)
	at ../../../gcc/libjava/java/lang/reflect/Modifier.java:302
    Value returned is $6 = 2

This return value is wrong in two ways:

* First, PUBLIC is 1, so the return value should be 0
* Second, the method returns a boolean so `2' is invalid anyway

// Demonstrate that private methods can be reflected even if they are
// not referenced at compile-time (i.e. -fkeep-inline-functions works).
import java.lang.reflect.Method;
public class KeepInline {
  private void example() {
    System.out.println("example");
  }
  public static void main(String[] args) {
    try {
      KeepInline pr = new KeepInline();
      Method[] meths = pr.getClass().getDeclaredMethods();
      for (int n = 0; n < meths.length; n++)
        System.out.println(meths[n]);
    } catch (Throwable t) {
      t.printStackTrace();
    }
  }
}
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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