[Bug c++/37070] bogus unreachable warning on throw statement
--- Comment #5 from bangerth at dealii dot org 2008-08-13 16:27 --- Confirmed. What I believe Andrew was pointing out are the internal reasons why this warning happens. However, the warning is clearly bogus, the flag -Wunreachable-code isn't useful if it warns on this sort of code. W. -- bangerth at dealii dot org changed: What|Removed |Added CC||bangerth at dealii dot org Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Last reconfirmed|-00-00 00:00:00 |2008-08-13 16:27:54 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37070
[Bug c++/37070] bogus unreachable warning on throw statement
--- Comment #1 from pinskia at gcc dot gnu dot org 2008-08-09 22:31 --- I don't think this is really bogus as the expression inside a throw cannot throw so GCC is able to optimize away the catch inside that throw. [t.cc : 3] try { [t.cc : 3] D.2413 = (int *) D.2410; [t.cc : 3] *D.2413 = 0; } catch { [t.cc : 3] eh_filter (NULL) { [t.cc : 3] terminate (); } } That catch is not reachable. -- pinskia at gcc dot gnu dot org changed: What|Removed |Added Severity|normal |enhancement http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37070
[Bug c++/37070] bogus unreachable warning on throw statement
--- 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
[Bug c++/37070] bogus unreachable warning on throw statement
--- Comment #3 from pinskia at gcc dot gnu dot org 2008-08-09 22:59 --- t.C: In function void bar(): t.C:2: warning: will never be executed I don't get that warning in either the trunk or in 4.0.1. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37070
[Bug c++/37070] bogus unreachable warning on throw statement
--- Comment #4 from sebor at roguewave dot com 2008-08-10 02:23 --- My gcc is yesterday's build: gcc version 4.4.0 20080808 (experimental) (GCC) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37070