public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* java/8298: Incomplete enforcement of constant expressions in switch/case
@ 2002-10-21  0:56 mcmartin
  0 siblings, 0 replies; only message in thread
From: mcmartin @ 2002-10-21  0:56 UTC (permalink / raw)
  To: gcc-gnats


>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:


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-10-21  7:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-21  0:56 java/8298: Incomplete enforcement of constant expressions in switch/case mcmartin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).