[LLVMbugs] [Bug 9954] New: set_terminate doesn't catch exceptions thrown by constructors invoked through new

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu May 19 13:24:29 PDT 2011


http://llvm.org/bugs/show_bug.cgi?id=9954

           Summary: set_terminate doesn't catch exceptions thrown by
                    constructors invoked through new
           Product: clang
           Version: 2.9
          Platform: Macintosh
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: source at sharpsteen.net
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


Simple test case:


#include <iostream>
#include <exception>

class Foo {
public:
  Foo(){
    throw "up";
  }

  ~Foo() {}
};

void crash_handler() {
  std::cout << "Exception thrown!" << std::endl;
  abort();
}

int main(int argc, char **argv){
  std::set_terminate(crash_handler);

  // This gets caught
  //Foo bar = Foo();

  // This doesn't
  Foo *bar = new Foo();

  return 0;
}


Output from GCC:

g++ -o foo exception_test.cpp
./foo

Exception thrown!
Abort trap


Output from Clang:

clang++ -o foo exception_test.cpp
./foo

Abort trap

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