Segmentation fault observed when a std::exception is thrown in a C++ program compiled with clang/llvm-5.0.0 as Objective-C++

Hello llvm-dev,

I am working to port a large compilation job from gcc to clang. The code compiles and runs correctly with clang on OSX/Darwin. However, I'm observing failures on Linux when I compile with clang/llvm-5.0.0 (the latest svn tree, checked out and built from scratch today), with libobjc2 as the Objective-C runtime. The proximate cause of the crashes is a NULL std::exception object. This is evident when I examine the stack from my minimal reproducer in gdb:

exceptionObject = 0x0

A more complicated program, which uses a custom C++ exception class derived from std::exception, also shows this symptom (here, the variable "e" is of the derived exception type):

e = @0x0: <error reading variable>

The minimal reproducing test program is entirely C++. The crash only occurs when I compiled it as a .mm (Objective-C++) program. When I compile it as plain C++ (.cc), the problem goes away and the program runs correctly.

I've attached the reproducing program (as .cc and .mm files that are otherwise identical), and compilation scripts C++ and Objective-C++ (to reproduce, just adjust the paths in the scripts). Any help here would be greatly appreciated.

Thank you,


Demonstration that the .cc and .mm programs are the same:
MD5 ( = 7a8ea3886e3e0550a96f8e1d235b7fae
MD5 ( = 7a8ea3886e3e0550a96f8e1d235b7fae (359 Bytes) (889 Bytes) (167 Bytes) (167 Bytes)

ATT00001.txt (4 Bytes)