public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/12668] New: Strange warnings with -O1 -Wunreachable-code in 3.3.1,3.3.2,3.4
@ 2003-10-18  4:25 rmerkert at alphatech dot com
  2003-10-18  4:29 ` [Bug c++/12668] " pinskia at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: rmerkert at alphatech dot com @ 2003-10-18  4:25 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12668

           Summary: Strange warnings with -O1 -Wunreachable-code in
                    3.3.1,3.3.2,3.4
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rmerkert at alphatech dot com
                CC: gcc-bugs at gcc dot gnu dot org

The following code produces a strange warning when compiled with
-Wunrechable-code and optimization:

cat > test.c <<EOF
inline void foo (int x)
{
   if (x!=0)
     x = x + 1;
}

int main ()
{
  foo(0);
/* if (0) { foo(1); } */  
  return 0;
}

EOF

gcc -O1 test.c -Wunreachable-code

The error message I get with both 3.3.1, 3.3.2, 3.4-20031001 is this:
test.c: In function `main':
test.c:4: warning: will never be executed

The message is somewhat misleading. I think it should either say something like:
test.c: In function 'foo':
test.c:4 warning: will never be executed

or 

test.c: In function 'main':
test.8: warning: will never be executed


By the way, if compiled with g++, there will be an extra empty line the output:
test.c: In function `main':

test.c:4: warning: will never be executed

and if you uncomment line 10 you'll get 4 warnings with 3.4 and 3 warnings with
3.3 and they are not helpful (gcc-3.3 doesn't even tell me about line 10).

I'm actually not sure I want the warning in this case - I really want the
compiler to tell me that a section of code cannot possibly be reached such as
"while (false) {}"


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

end of thread, other threads:[~2004-04-08 13:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-18  4:25 [Bug c++/12668] New: Strange warnings with -O1 -Wunreachable-code in 3.3.1,3.3.2,3.4 rmerkert at alphatech dot com
2003-10-18  4:29 ` [Bug c++/12668] " pinskia at gcc dot gnu dot org
2003-10-18 13:51 ` rmerkert at alphatech dot com
2003-10-18 14:05 ` rmerkert at alphatech dot com
2003-10-18 19:47 ` pinskia at gcc dot gnu dot org
2003-12-06  9:44 ` [Bug optimization/12668] " pinskia at gcc dot gnu dot org
2004-04-08 13:00 ` pinskia at gcc dot gnu dot org

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