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

David Blaikie dblaikie at gmail.com
Mon Oct 10 23:17:59 PDT 2011


On Mon, Oct 10, 2011 at 11:00 PM, Louis Gerbarg <lgerbarg at gmail.com> wrote:

> 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.
>
> Louis
>
> /* testcase.cpp
>   /Developer/usr/bin/clang++  --std=c++0x --stdlib=libc++ -fno-rtti
> testcase.cpp
> */
>
> //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;
> }
>

I can't seem to repro this with ToT clang/llvm/libc++ on linux x86-64. Could
you provide more details about your repro?

(& the resulting binary is valgrind clean too, which should reduce the
chance that I'm just seeing a different case of undefined behaviour than
you)

- David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111010/5549cd50/attachment.html>


More information about the cfe-dev mailing list