[LLVMbugs] [Bug 11351] New: warning about common incorrect usage of exceptions

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Nov 9 12:42:32 PST 2011


             Bug #: 11351
           Summary: warning about common incorrect usage of exceptions
           Product: clang
           Version: 2.9
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: vanyacpp at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

It would be great if clang showed warnings about common incorrect usage of
exceptions and appropriate fix-it hint.

That is:
1. "throw new"
2. catch by value
3. rethrow that change exception type

#include <stdexcept>

int main()
        throw new std::runtime_error("hello, kitty!"); // warning: "throw new",
fix-it: remove "new"
    catch (std::exception e) // warning: catch by value, fix-it: add "const&"
or "&"
        throw e; // warning: rethrow change a type, fix-it: remove "e"

    return 0;

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