Uncaught exceptions do not show what()

I am compiling with the latest Clang/LLVM on my Mac (10.7.2). Uncaught exceptions do not display the what() message from a std exception. Here’s my test program:

#include

using namespace std;

class my_exception : public exception{

virtual const char* what() const throw(){

return “my error occurred”;

}

};

int main(int argc, char** argv){

throw my_exception();

return 0;

}

Instead, I just get:

terminate called after throwing an instance of ‘my_exception’

terminate called without an active exception

Abort trap: 6

Nick

I am compiling with the latest Clang/LLVM on my Mac (10.7.2). Uncaught exceptions do not display the what() message from a std exception. Here’s my test program:

[ snip ]

Instead, I just get:

terminate called after throwing an instance of ‘my_exception’
terminate called without an active exception
Abort trap: 6

Here’s what I get with today’s clang (on 10.6.8):

$ clang --version
clang version 3.1 (trunk 142667)
Target: x86_64-apple-darwin10.8.0
Thread model: posix

$ clang++ junk.cpp && ./a.out
terminate called after throwing an instance of ‘my_exception’
what(): my error occurred
Abort trap

Maybe it’s a 10.6 vs. 10.7 thing ?

– Marshall

Marshall Clow Idio Software <mailto:mclow.lists@gmail.com>

A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait).
– Yu Suzuki

g++ produces the same result on Mac OS X 10.7.2. Please file a bug with Apple at

  https://bugreport.apple.com/

because what you're seeing is more likely a C++ runtime issue rather than a compiler issue.

  - Doug