public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Eric Blake <ebb9@email.byu.edu>
To: nobody@gcc.gnu.org
Cc: gcc-prs@gcc.gnu.org,
Subject: Re: java/5941: incorrect "Unreachable statement" error
Date: Mon, 01 Apr 2002 16:46:00 -0000	[thread overview]
Message-ID: <20020402004601.25946.qmail@sources.redhat.com> (raw)

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, 01 Apr 2002 17:42:18 -0700

 I finally received a reply from Neal Gafter, one of Sun's engineers,
 offline.  To summarize his position (as I don't think I am allowed to
 quote it):
 
 for (int i = 0; ; i++) break;
 
 is legal, even though i++ will never be executed, because i++ is not a
 complete statement and is therefore not subject to the rules of JLS
 14.20.
 
 In fact, this next program should be legal as well, based on the
 definite assignment rules for For statements in JLS chapter 16. Note
 that Sun's JDK 1.3 and 1.4 does not compile it, it has been recorded as
 Sun bug 4660984; Jikes also fails this example, jikes bug 2780:
 
 class C
 {
   void bar()
   {
     for (final int i; 0 < (i = 1); i = i + 1)
       break;
   }
 }
 
 
 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>     }
 > Saurin> }
 > 
 > Saurin> As you will notice that loop is exited after first iteration,
 > Saurin> and so the loop incrementer "i++" will never be executed.
 > 
 > Yes.  It looks like the language spec is unclear on this issue.
 > 
 > I'm looking at The Java Language Specification, 2nd Edition.  Section
 > 14.20 deals with unreachable statements.  The subsection on the `for'
 > statement doesn't mention conditions under which the update expression
 > is considered unreachable.
 > 
 > The Sun JDK 1.2 and 1.4 `javac' compilers don't give an error here,
 > which is suggestive but not authoritative.
 
 -- 
 This signature intentionally left boring.
 
 Eric Blake             ebb9@email.byu.edu
   BYU student, free software programmer


             reply	other threads:[~2002-04-02  0:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-01 16:46 Eric Blake [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-05-06 21:14 tromey
2002-04-25 11:47 tromey
2002-04-01 19:46 Per Bothner
2002-04-01 16:56 Tom Tromey
2002-03-25 14:46 Eric Blake
2002-03-25 13:26 Tom Tromey
2002-03-13 12:56 Saurin B. Shroff
2002-03-13 12:16 Tom Tromey
2002-03-13 11:36 shroff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020402004601.25946.qmail@sources.redhat.com \
    --to=ebb9@email.byu.edu \
    --cc=gcc-prs@gcc.gnu.org \
    --cc=nobody@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).