Bug 103192 - gcj: compiler error with valid Java syntax.
Summary: gcj: compiler error with valid Java syntax.
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 9
Hardware: i686
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Tom Tromey
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-08-27 16:10 UTC by Tony Reix
Modified: 2014-08-11 05:46 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2003-08-28 14:42:34 UTC
Embargoed:


Attachments (Terms of Use)

Description Tony Reix 2003-08-27 16:10:34 UTC
Description of problem:

gcj refuses a syntax accepted by javac.

Factory.java: In class `spec.jbb.infra.Factory.Factory':
Factory.java: In method `spec.jbb.infra.Factory.Factory.tempArray
Near(int,int)':
Factory.java:300: error: Unreachable statement.
                case T_CHAR:

The following syntax is refused by gcj:
	switch (type) {
		case T_BOOLEAN:
                {
                    result = new boolean[entries];
                    break;
                };
                case T_CHAR:
                {
                    result = new char[entries];
                    break;
                };
	etc.

Removing the {} inside the case code fixes the problem.


Version-Release number of selected component (if applicable):

# cat /etc/redhat-release
Red Hat Linux release 9 (Shrike)  2.4.20-8smp

# gcj --version
gcj (GCC) 3.3.1


How reproducible:

Easy.


Steps to Reproduce:

Welcome.java :

public class Welcome
{

static final int T_BOOLEAN = 4;
static final int T_CHAR = 5;

        public static void main(String[] args)
        {
                System.out.println("You're welcome!");
                System.out.println();         
        }

        private static Object pb (int type)
        {
         Object result = null;

                switch (type)
                {
                        case T_BOOLEAN:
                        {
                        result = new boolean[1];
                        break;
                        };
                        case T_CHAR:
                        {
                        result = new char[2];
                        break;
                        };
                }
                return result;
        }
}

    
Actual results:

Compiler error message.


Expected results:

No compiler error message.

Additional info:

Comment 1 Tom Tromey 2003-08-28 14:42:34 UTC
This isn't a bug.  Change both instances of "};" to "}"
in the switch statement and this code will compile -- those
semicolons are invalid.

FWIW both jikes and Sun JDK 1.4.2 also reject this code.

Thanks for a very easy-to-reproduce bug report.  This is the
kind I like.


Comment 2 Tony Reix 2003-08-28 15:26:50 UTC
This code compiled perfectly well with IBM javac 1.1.8 and IBM javac 1.3.1.
I've tried now to compile it with IBM java 1.4.1 : yes that fails !
So it seems to be some uncompatibility between Java 1.4 and previous versions.
Thanks for help.

Comment 3 Tom Tromey 2003-08-28 16:01:10 UTC
Yeah, just FYI, older versions of javac tended
to be more lenient with regard to extraneous semicolons.
At one point we added code to gcj to let it do this
too, but I think we only added cases where we had
access to code causing problems for us.  In any case,
it is a deprecated feature of the compiler (both
standard and gcj) -- best to fix the code.



Note You need to log in before you can comment on or make changes to this bug.