|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-03-24 13:23:36
Ananda Tallur wrote:
> Hello,
>
> Originally, I had discovered a problem when using
> boost::unit_test_framework, for which I have already posted.
> But, by further analysing the problem, I could come out to a simple
> program, using only boost shared pointers, and which fails :
> -> on Mac OS X 10.4
> -> when compiled with gcc 4.0.1 (coming with XCode 2.2.1), or gcc 4.1
> (delivered by darwin ports)
> -> with optimisations : at least -O, or -O1, or -O2,etc... It works
> correctly with -O0
> -> using either boost 1.33.1, 1.33.0, or 1.32.0
>
> Below is the sample test program :
>
> --- macosx_gcc4problem.cpp ---
[...]
This issue has already been reported, along with a fix, by Howard Hinnant:
http://lists.boost.org/Archives/boost/2006/03/102088.php
http://lists.boost.org/Archives/boost/2006/03/102122.php
http://lists.boost.org/Archives/boost/2006/03/102134.php
and the upcoming 1.34 release will no longer suffer from it.
Thank you very much for taking the time to simplify the failing example.
I've reformatted it a bit as a test case. If you verify that it still fails
for you, I'll include it in the regression tests.
#include <boost/shared_ptr.hpp>
#include <boost/detail/lightweight_test.hpp>
struct A
{
int value;
};
struct B
{
B( boost::shared_ptr<A> val ): a( val ) {}
boost::shared_ptr<A> a;
};
struct C
{
C( B val ): b( val ) {}
B b;
};
struct D
{
D( C val ): c( val ) {}
C c;
};
D create()
{
boost::shared_ptr <A> a( new A );
a->value = 12345;
return D( C( B( a ) ) );
}
int main()
{
D d = create();
BOOST_TEST( d.c.b.a->value == 12345 );
return boost::report_errors();
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk