[pkg-boost-devel] Bug#379897: boost compiles differently, if ACE header is included first

Harling, Torsten THarling at arri.de
Wed Jul 26 08:36:56 UTC 2006


Package: libboost-dev
Version: 1.32.0-6


This also relies to package libace-dev version 5.4.2.1.0-4.

Consider the following program boostfirst.cpp:
------------------------------------------------------------
#include <boost/shared_ptr.hpp>
#include <ace/OS.h>
#include <iostream>

using namespace std;

int main (int argc, char **argv)
{
    cout << "sizeof (boost::detail::sp_counted_base) == "
        << sizeof (boost::detail::sp_counted_base) << endl;
}
------------------------------------------------------------

Compile and run with:

$ g++ boostfirst.cpp -o boostfirst -lstd
$ ./boostfirst
sizeof (boost::detail::sp_counted_base) == 12


Now try including the ace header first (only the order of
the include files is changed):
------------------------------------------------------------
#include <ace/OS.h>
#include <boost/shared_ptr.hpp>
#include <iostream>

using namespace std;

int main (int argc, char **argv)
{
    cout << "sizeof (boost::detail::sp_counted_base) == "
        << sizeof (boost::detail::sp_counted_base) << endl;
}
------------------------------------------------------------

The output of the second program is:
sizeof (boost::detail::sp_counted_base) == 36

A great difference. The reason for this is, that the
#include <ace/OS.h> somehow defines _REENTRANT, which
triggers the boost library to include a mutex in
sp_counted_base. I think, the order of the includes
should not matter. Therefore, either '#include <ace/OS.h>'
should not define _REENTRANT, or the boost headers
should ignore it.

I found out, that adding the -pthread option to the
g++ command also avoids this bug.

Im using Debian sarge 3.1, g++ 3.3.5-3, libc6 2.3.2.ds1-22sarge3
and libace-dev 5.4.2.1.0-4.






More information about the pkg-boost-devel mailing list