Consider this simple program:

#include <string>
#include <iostream>

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE "MyTest"
#include <boost/test/unit_test.hpp>

using namespace std;

template<char* S>
void Test()
{
    BOOST_REQUIRE("Boom!" != string(S));
}

char bang[] = "Bang!";

BOOST_AUTO_TEST_CASE(Boom)
{
    char boom[] = "Boom!";
    Test<bang>();
}

I'm on Mac OS X v10.8.2 (Mountain Lion) and have XCode 4.5 installed.

The program works when compiled with GCC, for example,

gcc test.cpp -lboost_unit_test_framework-mt -lstdc++

but it crashes when compiled with Apple Clang 4.1 (tags/Apple/clang-421.11.65) (based on LLVM 3.1svn)

clang -std=c++11 -stdlib=libc++ -lc++ test.cpp -lboost_unit_test_framework-mt

I'm using Boost 1.51.0, installed using BREW. Recompiling Boost using Clang does not help.

Is there a solution to this mystery?

./a.out
Running 1 test case...

*** No errors detected
Segmentation fault: 11

gdb ./a.out
GNU gdb 6.3.50-20050815 (Apple version gdb-1822) (Sun Aug  5 03:00:42 UTC 2012)
...
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries .... done

(gdb) r
Starting program: /private/tmp/xx/a.out 
Reading symbols for shared libraries +++............................. done
Running 1 test case...

*** No errors detected

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: 13 at address: 0x0000000000000000
0x0000000100056c56 in boost::unit_test::test_unit::
Edit
Report