This service will be undergoing maintenance at 00:00 UTC, 2016-09-28. It is expected to last about 1 hours
Bug 103192 - gcj: compiler error with valid Java syntax.
gcj: compiler error with valid Java syntax.
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
9
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Tom Tromey
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-08-27 12:10 EDT by Tony Reix
Modified: 2014-08-11 01:46 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-08-28 10:42:34 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Tony Reix 2003-08-27 12:10:34 EDT
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 10:42:34 EDT
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 11:26:50 EDT
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 12:01:10 EDT
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.