This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
java/8298: Incomplete enforcement of constant expressions in switch/case
- From: mcmartin at stanford dot edu
- To: gcc-gnats at gcc dot gnu dot org
- Date: 21 Oct 2002 07:55:14 -0000
- Subject: java/8298: Incomplete enforcement of constant expressions in switch/case
- Reply-to: mcmartin at stanford dot edu
>Number: 8298
>Category: java
>Synopsis: Incomplete enforcement of constant expressions in switch/case
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: accepts-illegal
>Submitter-Id: net
>Arrival-Date: Mon Oct 21 00:56:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: mcmartin@stanford.edu
>Release: gcj 3.2
>Organization:
>Environment:
>Description:
The GCJ front-end should reject this, as the cases y.a and y.b don't match the definition of ConstantExpression in section 15.28 of the JLS (as required for cases in a switch in section 14.10 of the JLS):
public class test {
static final int a = 1;
static final int b = 2;
public static void main(String[] args) {
int x = 2;
test y = new test();
switch(x) {
case y.a:
System.out.println("Equal to a");
break;
case y.b:
System.out.println("Equal to b");
break;
default:
System.out.println("Something random");
break;
}
}
}
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: