[cfe-dev] False positive for -Wunreachable-code
Abramo Bagnara
abramo.bagnara at gmail.com
Tue Aug 3 08:22:03 PDT 2010
The following typescript shows that clang incorrectly seems to mark as
unreachable a throw of a temporary.
Please note that if I remove the destructor of struct s, no warning is
generated.
$ cat w.cc
struct s {
explicit s() { }
~s() { }
};
int f_bad(int x) {
if (x)
throw s();
return 0;
}
int f_good(int x) {
if (x) {
s e;
throw e;
}
return 0;
}
$ llvm/Debug+Asserts/bin/clang++ -Wunreachable-code -c w.cc
w.cc:8:5: warning: will never be executed [-Wunreachable-code]
throw s();
^~~~~~~~~
1 warning generated.
More information about the cfe-dev
mailing list