Opened 12 years ago

Closed 12 years ago

#37443 closed defect (invalid)

problem using boost_thread with -stdlib=libc++

Reported by: itsme@… Owned by: adfernandes (Andrew Fernandes)
Priority: Normal Milestone:
Component: ports Version: 2.1.2
Keywords: Cc:
Port: boost

Description

Given this very short test program:

#include <boost/thread.hpp>
int main(int,char**)
{
    boost::thread t([]() { /* nothing */ });
    t.join();
}

I compile this using the clang++ compiler ( either apple clang++ or macports clang++-mp-3.1 ) like this:

clang++ -stdlib=libc++ clangthread.cpp  -I /opt/local/include/ /opt/local/lib/libboost_thread-mt.dylib /opt/local/lib/libboost_system-mt.dylib  -std=c++11 -DBOOST_NO_CXX11_NUMERIC_LIMITS -o test_libc++-crashes

clang++ clangthread.cpp  -I /opt/local/include/ /opt/local/lib/libboost_thread-mt.dylib /opt/local/lib/libboost_system-mt.dylib  -std=c++11 -o test_libstdc++-nocrash

Now running the version using libc++, i get: Segmentation fault: 11 while the version with libstdc++ runs just fine.

When i don't call join both versions terminate without errors.

Change History (2)

comment:1 Changed 12 years ago by ryandesign (Ryan Carsten Schmidt)

Owner: changed from macports-tickets@… to adfernandes@…
Port: clang++ removed

I'm not sure this represents a bug in a MacPorts port, so you may have to contact the developers of the software for assistance.

comment:2 Changed 12 years ago by adfernandes (Andrew Fernandes)

Resolution: invalid
Status: newclosed

This is not a bug, it's a feature!

Seriously... the c++ standard library is very tightly coupled between headers and compiled code, so unless you're very, very careful when mixing compilation units, what you're seeing is a purposeful design (as per the StackOverflow commentary).

Note: See TracTickets for help on using tickets.