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: [email protected]
        ReportedBy: [email protected]
                CC: [email protected], [email protected]


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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to