This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/37070] bogus unreachable warning on throw statement
- From: "sebor at roguewave dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Aug 2008 22:51:41 -0000
- Subject: [Bug c++/37070] bogus unreachable warning on throw statement
- References: <bug-37070-1186@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from sebor at roguewave dot com 2008-08-09 22:51 -------
I'm not sure what you're trying to say but it sure looks like a bug to me.
How else is one supposed to throw an exception without triggering this
warning?
Btw., the argument of a throw expression can throw, and when it does, it
becomes the thrown object:
$ cat t.C && g++ -O2 -Wunreachable-code t.C && ./a.out; echo $?
struct S { S () { throw 0; } };
void bar () { throw S (); }
int main ()
{
try { bar (); }
catch (int) { return 0; }
return 1;
}
t.C: In constructor ?S::S()?:
t.C:1: warning: will never be executed
t.C: In function ?void bar()?:
t.C:2: warning: will never be executed
0
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37070