[Pkg-ace-devel] Bug#380739: boost compiles differently,
if ACE header is included first
Harling, Torsten
THarling at arri.de
Tue Aug 1 09:27:19 UTC 2006
Package: libace-dev
Version: 5.4.2.1.0-4
This also relies to package libboost-dev version 1.32.0-6.
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.
I've already sent this bug to the boost-dev package maintainer,
(I hoped they will forward this bug report to the libace-dev
package maintainer, but they didn't) and got the following
answer:
------------------------------------------------------------
hi :)
how this can be a boost's fault? there is a lot of code that compiles
differently in base of _REENTRANT. is it all broken?
if this surprises you, you didn't read ACE documentation or it does
not explain this nice side-effect of OS.h. anyway this is not related
with boost.
i'm closing the report.
cheers
domenico
------------------------------------------------------------
Im using Debian sarge 3.1, g++ 3.3.5-3, libc6 2.3.2.ds1-22sarge3,
libace-dev 5.4.2.1.0-4 and libboost-dev 1.32.0-6.
More information about the Pkg-ace-devel
mailing list