java/5941: incorrect "Unreachable statement" error

Eric Blake ebb9@email.byu.edu
Mon Mar 25 14:46:00 GMT 2002


The following reply was made to PR java/5941; it has been noted by GNATS.

From: Eric Blake <ebb9@email.byu.edu>
To: tromey@redhat.com
Cc: shroff@transeda.com, gcc-gnats@gcc.gnu.org,
 	Per Bothner <per@bothner.com>
Subject: Re: java/5941: incorrect "Unreachable statement" error
Date: Mon, 25 Mar 2002 15:38:03 -0700

 I raised this very question, nearly two months ago, to the Java Spec
 Report mailing list, but never received an answer.
 
 http://groups.yahoo.com/group/java-spec-report/message/636
 
 I know that Neal Gafter, one of Sun's engineers, reads that list, so he
 may have entered my report on the Sun bug database, but I haven't seen
 any response on the matter.  I can ask him further, to see what he
 thinks about the situation.
 
 My personal feeling about the situation: Saurin's example code should
 not compile, because it has an unreachable statement (the statement
 "return l2;" is unreachable according to JLS 14.20).  However, I am
 inclined to treat the i++ statement is reachable, even if it is never
 executed.  The JLS definitely has a hole in not specifing anything about
 the reachability of the i++, but both jikes and javac permit unexecuted
 ForUpdate statements.
 
 Tom Tromey wrote:
 > 
 > Saurin> public class bug2 {
 > Saurin>     public static int showBug2 () {
 > Saurin>         for (int i=0; i <= 10; i++) {
 > Saurin>             if ( i > 3 ) {
 > Saurin>                 return 10;
 > Saurin>             } else {
 > Saurin>                 return 11;
 > Saurin>             }
 > Saurin>         }
 > Saurin>         return 12;
 > Saurin>     }
 > Saurin> }
 > 
 > 
 > Yes.  It looks like the language spec is unclear on this issue.
 > 
 
 I agree with that conclusion - the JLS needs clarification on ForUpdate
 statements, both in reachability, and in definite assignment.
 
 > 
 > Saurin> What I would suggest that "Unreachable statement" should be a
 > Saurin> warning rather than error since it stops the compilation
 > 
 > The language specification requires an error for unreachable code.
 
 Tom's right here - unreachable code must be a compile-time error, not a
 warning.
 
 -- 
 This signature intentionally left boring.
 
 Eric Blake             ebb9@email.byu.edu
   BYU student, free software programmer



More information about the Gcc-prs mailing list