public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: java/5941: incorrect "Unreachable statement" error
@ 2002-04-25 11:47 tromey
  0 siblings, 0 replies; 10+ messages in thread
From: tromey @ 2002-04-25 11:47 UTC (permalink / raw)
  To: ebb9, gcc-bugs, gcc-prs, java-prs, nobody, shroff, tromey

Synopsis: incorrect "Unreachable statement" error

Responsible-Changed-From-To: unassigned->tromey
Responsible-Changed-By: tromey
Responsible-Changed-When: Thu Apr 25 11:47:28 2002
Responsible-Changed-Why:
    I'm handling this.
State-Changed-From-To: open->analyzed
State-Changed-By: tromey
State-Changed-When: Thu Apr 25 11:47:28 2002
State-Changed-Why:
    First version of patch submitted.
    Next revision coming soon.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5941


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: java/5941: incorrect "Unreachable statement" error
@ 2002-05-06 21:14 tromey
  0 siblings, 0 replies; 10+ messages in thread
From: tromey @ 2002-05-06 21:14 UTC (permalink / raw)
  To: ebb9, gcc-bugs, gcc-prs, java-prs, shroff, tromey

Synopsis: incorrect "Unreachable statement" error

State-Changed-From-To: analyzed->closed
State-Changed-By: tromey
State-Changed-When: Mon May  6 21:14:44 2002
State-Changed-Why:
    I've checked in a fix for this.
    It will appear in gcj 3.2 (maybe 3.1.1, but don't count on it)

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5941


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: java/5941: incorrect "Unreachable statement" error
@ 2002-04-01 19:46 Per Bothner
  0 siblings, 0 replies; 10+ messages in thread
From: Per Bothner @ 2002-04-01 19:46 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

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

From: Per Bothner <per@bothner.com>
To: tromey@redhat.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: java/5941: incorrect "Unreachable statement" error
Date: Mon, 01 Apr 2002 19:46:58 -0800

 Tom Tromey wrote:
 >>>>>>"Eric" == Eric Blake <ebb9@email.byu.edu> writes:
 >>>>>
 > 
 > Eric> for (int i = 0; ; i++) break;
 > Eric> is legal, even though i++ will never be executed, because i++ is
 > Eric> not a complete statement and is therefore not subject to the
 > Eric> rules of JLS 14.20.
 
 It any case I think we should emit a warning for this case, since it
 indicates a bug in the user's code.
 
 For the same reason, while emitting an error is technically a bug
 in the compiler, fixing it seems low-priority.
 
 > One approach to fixing it would be to introduce a new FOR tree, which
 > we could then handle specially in check-init.  Then later we would
 > lower this FOR to a LOOP_EXPR.
 
 That sounds reasonable.
 -- 
 	--Per Bothner
 per@bothner.com   http://www.bothner.com/per/
 


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: java/5941: incorrect "Unreachable statement" error
@ 2002-04-01 16:56 Tom Tromey
  0 siblings, 0 replies; 10+ messages in thread
From: Tom Tromey @ 2002-04-01 16:56 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

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

From: Tom Tromey <tromey@redhat.com>
To: Eric Blake <ebb9@email.byu.edu>
Cc: shroff@transeda.com, gcc-gnats@gcc.gnu.org, Per Bothner <per@bothner.com>
Subject: Re: java/5941: incorrect "Unreachable statement" error
Date: 01 Apr 2002 17:57:19 -0700

 >>>>> "Eric" == Eric Blake <ebb9@email.byu.edu> writes:
 
 Eric> for (int i = 0; ; i++) break;
 Eric> is legal, even though i++ will never be executed, because i++ is
 Eric> not a complete statement and is therefore not subject to the
 Eric> rules of JLS 14.20.
 
 Thanks for looking into this.  Unfortunately it looks difficult to fix
 the bug due to how loops are represented in gcj.
 
 One approach to fixing it would be to introduce a new FOR tree, which
 we could then handle specially in check-init.  Then later we would
 lower this FOR to a LOOP_EXPR.  We'll want to do something like this
 anyway for the AST work.
 
 Tom


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: java/5941: incorrect "Unreachable statement" error
@ 2002-04-01 16:46 Eric Blake
  0 siblings, 0 replies; 10+ messages in thread
From: Eric Blake @ 2002-04-01 16:46 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: java/5941: incorrect "Unreachable statement" error
@ 2002-03-25 14:46 Eric Blake
  0 siblings, 0 replies; 10+ messages in thread
From: Eric Blake @ 2002-03-25 14:46 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: java/5941: incorrect "Unreachable statement" error
@ 2002-03-25 13:26 Tom Tromey
  0 siblings, 0 replies; 10+ messages in thread
From: Tom Tromey @ 2002-03-25 13:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

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

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

 >>>>> "Saurin" == Saurin B Shroff <shroff@transeda.com> writes:
 
 Hi.  I looked at this PR a little more today.
 
 Saurin> Following is a simplified code that shows this behavior:
 
 In your original code the loop didn't appear to always complete
 abnormally.  So this code looks different.  We might be seeing two
 different problems.
 
 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> }
 
 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.
 
 I think what gcj does is reasonable.  This might simply be a bug in
 the language spec.  However, I'm not certain.  Perhaps there is a
 subtle reason for this omission.
 
 Eric, Per, what do you think?
 
 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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: java/5941: incorrect "Unreachable statement" error
@ 2002-03-13 12:56 Saurin B. Shroff
  0 siblings, 0 replies; 10+ messages in thread
From: Saurin B. Shroff @ 2002-03-13 12:56 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

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

From: "Saurin B. Shroff" <shroff@transeda.com>
To: tromey@redhat.com
Cc: gcc-gnats@gcc.gnu.org, Saurin Shroff <shroff@transeda.com>
Subject: Re: java/5941: incorrect "Unreachable statement" error
Date: Wed, 13 Mar 2002 15:49:07 -0500

 Thanks a lot for a quick response...
 
 I had similar error in three other files with no apparent similarities.
 Upon closer look, I found that all four loops had one thing common:
 they all exited the loop after first iteration. Some of them "returned"
 after first iteration, some "break"ed from the loop.
 
 Following is a simplified code that shows this behavior:
 
 public class bug2 {
 
     public static int showBug2 () {
 	for (int i=0; i <= 10; i++) {
 	    if ( i > 3 ) {
 		return 10;
 	    } else {
 		return 11;
 	    }
 	}
 
 	return 12;
     }
 }
 
 As you will notice that loop is exited after first iteration, and so the
 loop incrementer "i++" will never be executed.
 
 So it seems that we have found some bugs in our code thanks to GCJ.
 
 What I would suggest that "Unreachable statement" should be a warning
 rather than error since it stops the compilation
 
 -- Saurin
 
 Tom Tromey wrote:
 > 
 > >>>>> "Saurin" == shroff  <shroff@transeda.com> writes:
 > 
 > Saurin> Synopsis:       incorrect "Unreachable statement" error
 > Saurin> Release:        GNU Java version 3.0.1 (sparc-sun-solaris2.8)
 > 
 > Saurin> hdlFSM.java:448: Unreachable statement.
 > Saurin>             for (int i=lowIndex; i <= highIndex; i++) {
 > Saurin>                                                        ^
 > Saurin> 1 error
 > 
 > Do you have a small (one or two files) test case?
 > Or can you easily try the gcj from the 3.1 CVS branch?
 > 
 > As I recall this code has been substantially improved in 3.1.
 > I imagine your bug has already been fixed.
 > 
 > Tom


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: java/5941: incorrect "Unreachable statement" error
@ 2002-03-13 12:16 Tom Tromey
  0 siblings, 0 replies; 10+ messages in thread
From: Tom Tromey @ 2002-03-13 12:16 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

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

From: Tom Tromey <tromey@redhat.com>
To: shroff@transeda.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: java/5941: incorrect "Unreachable statement" error
Date: 13 Mar 2002 13:39:45 -0700

 >>>>> "Saurin" == shroff  <shroff@transeda.com> writes:
 
 Saurin> Synopsis:       incorrect "Unreachable statement" error
 Saurin> Release:        GNU Java version 3.0.1 (sparc-sun-solaris2.8)
 
 Saurin> hdlFSM.java:448: Unreachable statement.
 Saurin>             for (int i=lowIndex; i <= highIndex; i++) {
 Saurin>                                                        ^
 Saurin> 1 error
 
 Do you have a small (one or two files) test case?
 Or can you easily try the gcj from the 3.1 CVS branch?
 
 As I recall this code has been substantially improved in 3.1.
 I imagine your bug has already been fixed.
 
 Tom


^ permalink raw reply	[flat|nested] 10+ messages in thread

* java/5941: incorrect "Unreachable statement" error
@ 2002-03-13 11:36 shroff
  0 siblings, 0 replies; 10+ messages in thread
From: shroff @ 2002-03-13 11:36 UTC (permalink / raw)
  To: gcc-gnats


>Number:         5941
>Category:       java
>Synopsis:       incorrect "Unreachable statement" error
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 13 11:36:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Saurin Shroff
>Release:        GNU Java version 3.0.1 (sparc-sun-solaris2.8)
>Organization:
>Environment:
Sun/Sparc Solaris
>Description:
I get:

hdlFSM.java:448: Unreachable statement.
            for (int i=lowIndex; i <= highIndex; i++) {
                                                       ^
1 error

The variable lowIndex and highIndex are set just before the
loop. Here is the partial code:

    int highIndex = dependency.hdlmGetHighIndex();
    int lowIndex = dependency.hdlmGetLowIndex();

    for (int i=lowIndex; i <= highIndex; i++) {
	if ( dependencyDeclaration.hdlmIsRegister(i) ||
	     dependencyDeclaration.hdlmIsLatch(i) ) {
	    /* encountered a register other then state variable */
	    return true;
	}

Object "dependency" is of type "hdlDependency" which is an
interface. The hdlmGetHighIndex and hdlmGetLowIndex are
methods described in the interface and are implemented in
classes that implement the interface.

There was one similar loop in the file before line 448, but
no error was issued against it.

Here is the command line I used and the result:

% gcj -v -C --encoding=UTF-8 -CLASSPATH /home/shroff/work hdlFSM.java

Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0.1/specs
Configured with: ../configure --with-as=/usr/local/bin/as --with-ld=/usr/local/bin/ld --enable-libgcj
Thread model: posix
gcc version 3.0.1
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0.1/jc1 hdlFSM.java -quiet -dumpbase hdlFSM.java -g1 -version -fencoding=UTF-8 -fencoding=UTF-8 -fCLASSPATH=/home/shroff/work -fsyntax-only -femit-class-files -o /dev/null
GNU Java version 3.0.1 (sparc-sun-solaris2.8)
        compiled by GNU C version 3.0.1.
hdlFSM.java: In class `dualsoft.rules.hdlFSM':
hdlFSM.java: In method `dualsoft.rules.hdlFSM.checkForPIAndNonStateVariables(java.util.Vector,dualsoft.rules.hdlDeclInterface,dualsoft.rules.hdlDeclInterface)':
hdlFSM.java:448: Unreachable statement.
            for (int i=lowIndex; i <= highIndex; i++) {
                                                       ^
1 error

Le me know if you want any other information.

-- Saurin
   shroff@transeda.com

P.S
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2002-05-07  4:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-25 11:47 java/5941: incorrect "Unreachable statement" error tromey
  -- strict thread matches above, loose matches on Subject: below --
2002-05-06 21:14 tromey
2002-04-01 19:46 Per Bothner
2002-04-01 16:56 Tom Tromey
2002-04-01 16:46 Eric Blake
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

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).