[LLVMbugs] [Bug 7802] New: False positive for -Wunreachable-code

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Aug 3 13:20:58 PDT 2010


           Summary: False positive for -Wunreachable-code
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: abramobagnara at tin.it
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com

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

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

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list