Bug 2631 - switch indexed by class crashes compiler
Summary: switch indexed by class crashes compiler
Alias: None
Product: frysk
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
: P3 normal
Target Milestone: ---
Assignee: Andrew Cagney
Depends on:
Blocks: 1839
  Show dependency treegraph
Reported: 2006-05-02 14:17 UTC by Andrew Cagney
Modified: 2007-03-08 21:13 UTC (History)
1 user (show)

See Also:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Cagney 2006-05-02 14:17:59 UTC

cagney@nettle$ cat frysk-imports/tests/EnumClass.java
class EnumClass
    static public final EnumClass x = new EnumClass ();
cagney@nettle$ cat frysk-imports/tests/ClassSwitch.java
class ClassSwitch
    public static void main (String[] args)
        switch (args.length) {
        case EnumClass.x: return;
        System.out.println ("Switched");
cagney@nettle$ gcj -I frysk-imports/tests frysk-imports/tests/ClassSwitch.java
frysk-imports/tests/ClassSwitch.java:5: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugzilla.redhat.com/bugzilla> for instructions.
Comment 1 Andrew Cagney 2006-05-02 19:37:30 UTC
Upstream tracker:
Comment 2 Andrew Cagney 2006-05-02 19:37:59 UTC
Index: frysk-imports/tests/ChangeLog
2006-05-02  Andrew Cagney  <cagney@redhat.com>

        * Makefile.am (frysk2630/noerror.sh, frysk2631/ice.sh): Add rules.
        * frysk2630/ClassIndex.java: New.
        * frysk2631/EnumClass.java: New.
        * frysk2631/ClassSwitch.java: New.
Comment 3 Mark Wielaard 2007-03-08 19:30:14 UTC
This doesn't crash the compiler anymore with gcc version 4.1.2 20070222 (Red Hat

Note however that it is invalid code:
$ gcj -I ../../../frysk/frysk-imports/tests/frysk2631 -d .
../../../frysk/frysk-imports/tests/frysk2631/ClassSwitch.java:6: error: Type
mismatch: cannot convert from EnumClass to int
        case EnumClass.x: return;
1 problem (1 error)
$ echo $?

So this testcase will never PASS.
Since there is no way to distinquish between the two exit states I think this
test should just be removed.
Comment 4 Andrew Cagney 2007-03-08 20:54:45 UTC
2>&1 | grep internal compiler error

gives the status you need
Comment 5 Mark Wielaard 2007-03-08 21:13:56 UTC
(In reply to comment #4)
> 2>&1 | grep internal compiler error
> gives the status you need

Good idea. Checked in:

2007-03-08  Mark Wielaard  <mark@klomp.org>

   * Makefile.am (frysk2631/ice.sh): Grep for 'internal compiler error:'.

Which makes frysk2631/ice.sh XFAIL with FC5/6 gcj, but now XPASSes with rawhide gcj.