public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: rcampbell@tropicnetworks.com
To: gcc-gnats@gcc.gnu.org
Subject: c/8828: gcc reports some code is unreachable when it is not
Date: Thu, 05 Dec 2002 13:06:00 -0000	[thread overview]
Message-ID: <20021205210447.31385.qmail@sources.redhat.com> (raw)


>Number:         8828
>Category:       c
>Synopsis:       gcc reports some code is unreachable when it is not
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Thu Dec 05 13:06:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Rolf Campbell
>Release:        GNU C version 3.2 20020927 (prerelease) (i686-pc-cygwin)
>Organization:
>Environment:
Cygwin 1.3.17 running under Win2000 (SP3)
>Description:
When gcc is run with "-Wunreachable-code", certain reachable code sections involving switch's generate warnings about unreachable code.

Here's "a.i"
# 1 "a.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "a.c"
int b;

int func(int a)
{
  int j = 2;
  switch(a) {
    case 0:
      for(j=0; j<b; j++)
        j++;
      break;
    case 1:
      for(j=0; j<3; j++)
        j++;
      break;
  }
  return j;
}

When I compile it with
gcc -v -save-temps -Wunreachable-code -c a.c

I get:
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.2/specs
Configured with: /netrel/src/gcc-3.2-3/configure --enable-languages=c,c++,f77,java --enable-libgcj --enable-threads=posix --with-system-zlib --enable-nls --without-included-gettext --enable-interpreter --disable-sjlj-exceptions --disable-version-specific-runtime-libs --enable-shared --build=i686-pc-linux --host=i686-pc-cygwin --target=i686-pc-cygwin --enable-haifa --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --includedir=/nonexistent/include --libexecdir=/usr/sbin
Thread model: posix
gcc version 3.2 20020927 (prerelease)
 /usr/lib/gcc-lib/i686-pc-cygwin/3.2/cpp0.exe -lang-c -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=0 -D__GXX_ABI_VERSION=102 -D_X86_=1 -D_X86_=1 -Asystem=winnt -D__NO_INLINE__ -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ -D__tune_pentium2__ -D__tune_pentium3__ -D__stdcall=__attribute__((__stdcall__)) -D__fastcall=__attribute__((__fastcall__)) -D__cdecl=__attribute__((__cdecl__)) -D_stdcall=__attribute__((__stdcall__)) -D_fastcall=__attribute__((__fastcall__)) -D_cdecl=__attribute__((__cdecl__)) -D__declspec(x)=__attribute__((x)) -D__i386__ -D__i386 -D__CYGWIN32__ -D__CYGWIN__ -Dunix -D__unix__ -D__unix -isystem /usr/lib/gcc-lib/i686-pc-cygwin/3.2/../../../../include/w32api -isystem /usr/lib/gcc-lib/i686-pc-cygwin/3.2/../../../../i686-pc-cygwin/lib/../../include/w32api a.c -Wunreachable-code a.i
GNU CPP version 3.2 20020927 (prerelease) (cpplib) (80386, BSD syntax)
ignoring nonexistent directory "/usr/i686-pc-cygwin/include"
ignoring duplicate directory "/usr/i686-pc-cygwin/lib/../../include/w32api"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/w32api
 /usr/local/include
 /usr/lib/gcc-lib/i686-pc-cygwin/3.2/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/i686-pc-cygwin/3.2/cc1.exe -fpreprocessed a.i -quiet -dumpbase a.c -Wunreachable-code -version -o a.s
GNU CPP version 3.2 20020927 (prerelease) (cpplib) (80386, BSD syntax)
GNU C version 3.2 20020927 (prerelease) (i686-pc-cygwin)
        compiled by GNU C version 3.2 20020927 (prerelease).
a.c: In function `func':
a.c:10: warning: will never be executed
a.c:14: warning: will never be executed
>How-To-Repeat:

>Fix:

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


             reply	other threads:[~2002-12-05 21:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-05 13:06 rcampbell [this message]
2002-12-06  1:29 reichelt
2002-12-06  8:16 Christian Ehrhardt
2002-12-06  8:26 Rolf Campbell
2002-12-06 15:56 Wolfgang Bangerth
2002-12-06 17:06 Christian Ehrhardt

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=20021205210447.31385.qmail@sources.redhat.com \
    --to=rcampbell@tropicnetworks.com \
    --cc=gcc-gnats@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).