Hello,
I would like to submit a strange problem we recently discovered, when
using boost_unit_test.
This problem only occurs : on Mac OS X, when using gcc 4 with any
optimization level other than 0 (-O, -O1, -O2, etc...).
I have tested with gcc 4.0.1 (build 5250 coming with Apple XCode
2.2.1), and also gcc 4.0.2 delivered by darwinports, and the problem
is the same.
On the other hand, it works perfectly on Linux, with gcc 4.0.2 and
optimizations.
The problem :
it occurs when using BOOST_CLASS_TEST_CASE.
BOOST_CLASS_TEST_CASE executes a test method of a class/struct
instance, so that the class/struct attributes can be used in the
test. With a very simple class, named SampleTest, having only
-> one int attribute "a"
-> a single test function : void sampleTest (), which only displays
value of "a"
-> a test declared in boost test suite : BOOST_CLASS_TEST_CASE ( &
SampleTest::sampleTest, instance), with instance being shared pointer
to a instance of sampleTest, instanciated with a given value of "a"
passed as constructor argument.
It does not work on Mac OS X, with the conditions described above.
Everything happens as if BOOST_CLASS_TEST_CASE was not using the
correct address in memory for accessing the instance attributes data.
Furthermore, the value displayed for a is wrong, but always the same,
it is not random at all, which seems to mean that there is a shift in
the memory adress being accessed.
Below is the complete sample program, for reproducing the problem :
---- file boost_unit_test_gcc4_pb_sample.cpp ---
#include <iostream>
#include