public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/25181] New: wrong "will never be executed" warning in switch - case block
@ 2005-11-30 15:52 oliverst at online dot de
2005-11-30 16:09 ` [Bug c++/25181] " pinskia at gcc dot gnu dot org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: oliverst at online dot de @ 2005-11-30 15:52 UTC (permalink / raw)
To: gcc-bugs
The following code will report this:
C:\Dev-Cpp\Projects\test-stlport\main_18.cpp In function `int test_18()':
13 C:\Dev-Cpp\Projects\test-stlport\main_18.cpp [Warning] will never be
executed
extern int abort();
int test_18()
{
int type;
switch (type)
{
case 1:
int ret = abort();
if (ret != 0)
return 2;
break;
case 3:
break;
default:
return 1;
}
return 0;
}
If you remove "case 3" or "default" the warning will go away.
I already reported something similar under bug 24968.
C:\MinGW_3.4.4\bin>gcc -v
Reading specs from ../lib/gcc/mingw32/3.4.4/specs
Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as
--host=
mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls
--enable
-languages=c,c++,f77,ada,objc,java --disable-win32-registry --disable-shared
--e
nable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x
--enable-ja
va-gc=boehm --disable-libgcj-debug --enable-interpreter
--enable-hash-synchroniz
ation --enable-libstdcxx-debug
Thread model: win32
gcc version 3.4.4 (mingw special)
--
Summary: wrong "will never be executed" warning in switch - case
block
Product: gcc
Version: 3.4.4
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: oliverst at online dot de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25181
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/25181] wrong "will never be executed" warning in switch - case block
2005-11-30 15:52 [Bug c++/25181] New: wrong "will never be executed" warning in switch - case block oliverst at online dot de
@ 2005-11-30 16:09 ` pinskia at gcc dot gnu dot org
2005-11-30 16:11 ` [Bug c++/25181] [3.4 Regression] " pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-30 16:09 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 405 bytes --]
------- Comment #1 from pinskia at gcc dot gnu dot org 2005-11-30 16:08 -------
This is invalid code:
t.cc: In function int test_18():
t.cc:15: error: jump to case label
t.cc:9: error: crosses initialization of int ret
t.cc:18: error: jump to case label
t.cc:9: error: crosses initialization of int ret
We should reject this.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25181
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/25181] [3.4 Regression] wrong "will never be executed" warning in switch - case block
2005-11-30 15:52 [Bug c++/25181] New: wrong "will never be executed" warning in switch - case block oliverst at online dot de
2005-11-30 16:09 ` [Bug c++/25181] " pinskia at gcc dot gnu dot org
@ 2005-11-30 16:11 ` pinskia at gcc dot gnu dot org
2005-11-30 20:38 ` oliverst at online dot de
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-30 16:11 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2005-11-30 16:11 -------
(In reply to comment #1)
> We should reject this.
But that is a different bug.
Anyways fixing up the code to be legal code:
extern int abort();
int test_18()
{
int type;
switch (type)
{
case 1:
{ int ret = abort();
if (ret != 0)
return 2;
break;}
case 3:
break;
default:
return 1;
}
return 0;
}
---
We only warn for 3.4.x and below except 3.0.4 works so this is only a 3.4
regression.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |diagnostic
Known to fail| |3.3.3 3.4.0
Known to work| |3.0.4 4.0.0 4.1.0 4.2.0
Last reconfirmed|0000-00-00 00:00:00 |2005-11-30 16:11:44
date| |
Summary|wrong "will never be |[3.4 Regression] wrong "will
|executed" warning in switch |never be executed" warning
|- case block |in switch - case block
Target Milestone|--- |3.4.6
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25181
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/25181] [3.4 Regression] wrong "will never be executed" warning in switch - case block
2005-11-30 15:52 [Bug c++/25181] New: wrong "will never be executed" warning in switch - case block oliverst at online dot de
2005-11-30 16:09 ` [Bug c++/25181] " pinskia at gcc dot gnu dot org
2005-11-30 16:11 ` [Bug c++/25181] [3.4 Regression] " pinskia at gcc dot gnu dot org
@ 2005-11-30 20:38 ` oliverst at online dot de
2005-11-30 22:23 ` [Bug middle-end/25181] " gdr at integrable-solutions dot net
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: oliverst at online dot de @ 2005-11-30 20:38 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from oliverst at online dot de 2005-11-30 20:38 -------
I forgot to meintion, that this happens with C and C++, so I guess it's a
middle-end bug!?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25181
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/25181] [3.4 Regression] wrong "will never be executed" warning in switch - case block
2005-11-30 15:52 [Bug c++/25181] New: wrong "will never be executed" warning in switch - case block oliverst at online dot de
` (2 preceding siblings ...)
2005-11-30 20:38 ` oliverst at online dot de
@ 2005-11-30 22:23 ` gdr at integrable-solutions dot net
2005-12-01 12:32 ` oliverst at online dot de
2006-03-01 5:01 ` gdr at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: gdr at integrable-solutions dot net @ 2005-11-30 22:23 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from gdr at integrable-solutions dot net 2005-11-30 22:23 -------
Subject: Re: [3.4 Regression] wrong "will never be executed" warning in switch
- case block
"oliverst at online dot de" <gcc-bugzilla@gcc.gnu.org> writes:
| I forgot to meintion, that this happens with C and C++, so I guess it's a
| middle-end bug!?
Most probably.
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25181
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/25181] [3.4 Regression] wrong "will never be executed" warning in switch - case block
2005-11-30 15:52 [Bug c++/25181] New: wrong "will never be executed" warning in switch - case block oliverst at online dot de
` (3 preceding siblings ...)
2005-11-30 22:23 ` [Bug middle-end/25181] " gdr at integrable-solutions dot net
@ 2005-12-01 12:32 ` oliverst at online dot de
2006-03-01 5:01 ` gdr at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: oliverst at online dot de @ 2005-12-01 12:32 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1434 bytes --]
------- Comment #5 from oliverst at online dot de 2005-12-01 12:32 -------
(In reply to comment #1)
> This is invalid code:
> t.cc: In function int test_18():
> t.cc:15: error: jump to case label
> t.cc:9: error: crosses initialization of int ret
> t.cc:18: error: jump to case label
> t.cc:9: error: crosses initialization of int ret
>
> We should reject this.
>
Will you create a bug report for this or is there already one filed?
I just tried it with GCC 4.0.2 (downloaded it from
http://www.thisiscool.com/gcc_mingw.htm) and the code is still accepted.
C:\MinGW_4.0.2\bin>gcc -v
Using built-in specs.
Target: i686-pc-mingw32
Configured with: /datal/gcc/gcc/configure --prefix=/datal/gcc/build/wingcc
--bui
ld=i686-pc-linux-gnu --host=i686-pc-mingw32 --target=i686-pc-mingw32
--enable-la
nguages=c,c++,java --with-gcc --with-gnu-as --with-gnu-ld
--with-as=/datal/gcc/b
uild/crossgcc/bin/i686-pc-mingw32-as
--with-ld=/datal/gcc/build/crossgcc/bin/i68
6-pc-mingw32-ld --enable-threads=win32 --disable-nls --disable-win32-registry
--
disable-shared --disable-debug --without-newlib --enable-libgcj
--disable-java-a
wt --without-x --enable-java-gc=boehm --disable-libgcj-debug
--enable-interprete
r --enable-hash-synchronization --enable-sjlj-exceptions
--enable-libgcj-multifi
le --enable-libgcj-mingw-osapi=ansi
Thread model: win32
gcc version 4.0.2
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25181
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/25181] [3.4 Regression] wrong "will never be executed" warning in switch - case block
2005-11-30 15:52 [Bug c++/25181] New: wrong "will never be executed" warning in switch - case block oliverst at online dot de
` (4 preceding siblings ...)
2005-12-01 12:32 ` oliverst at online dot de
@ 2006-03-01 5:01 ` gdr at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: gdr at gcc dot gnu dot org @ 2006-03-01 5:01 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from gdr at gcc dot gnu dot org 2006-03-01 05:01 -------
Fixed in 4.0.0 and up.
--
gdr at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|3.4.6 |4.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25181
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-03-01 5:01 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-30 15:52 [Bug c++/25181] New: wrong "will never be executed" warning in switch - case block oliverst at online dot de
2005-11-30 16:09 ` [Bug c++/25181] " pinskia at gcc dot gnu dot org
2005-11-30 16:11 ` [Bug c++/25181] [3.4 Regression] " pinskia at gcc dot gnu dot org
2005-11-30 20:38 ` oliverst at online dot de
2005-11-30 22:23 ` [Bug middle-end/25181] " gdr at integrable-solutions dot net
2005-12-01 12:32 ` oliverst at online dot de
2006-03-01 5:01 ` gdr 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).