[cfe-dev] In libc++ is std::make_shared supposed to have a dependency on RTTI?

Louis Gerbarg lgerbarg at gmail.com
Mon Oct 10 23:00:04 PDT 2011

During migrating some code from various hand rolled smart pointers to
C++11 stuff I noticed a crash, and I am not sure if it is due to a bug
in libc++ or me not understanding some of the dependencies in the new
C++ standard. I was seeing crashes in ~shared_ptr, it appears to be
walking into garbage, presumably looking for type info (the code has
always been compiled -fno-rtti). If I turn on RTTI it goes away, and
if I manually construct the shared_ptr instead of using make_shared it
also goes away.

Below is a reduced test case that shows what is going on. If this
dependency should not exist I am happy to file a bug, but I wanted to
confirm that it is in fact a bug.


/* testcase.cpp
   /Developer/usr/bin/clang++  --std=c++0x --stdlib=libc++ -fno-rtti

//Crashes on scope collapse when ~shared_ptr is called.
// Crash goes away if RTTI is turned on
// Crash also goes away if the "SharedTest test = SharedTest(NULL);"
instead of std::make_shared

#include <memory>

typedef std::shared_ptr<void *> SharedTest;

int main (void) {
  SharedTest test = std::make_shared<void *>(NULL);
  return 0;

More information about the cfe-dev mailing list