From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21372 invoked by alias); 13 Mar 2002 20:56:05 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 21280 invoked by uid 71); 13 Mar 2002 20:56:03 -0000 Date: Wed, 13 Mar 2002 12:56:00 -0000 Message-ID: <20020313205603.21264.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: "Saurin B. Shroff" Subject: Re: java/5941: incorrect "Unreachable statement" error Reply-To: "Saurin B. Shroff" X-SW-Source: 2002-03/txt/msg00447.txt.bz2 List-Id: The following reply was made to PR java/5941; it has been noted by GNATS. From: "Saurin B. Shroff" To: tromey@redhat.com Cc: gcc-gnats@gcc.gnu.org, Saurin Shroff 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 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