build error using sharable_lock with -02 optimization

I'm trying to use the Boost.Interprocess library, mutexes, scoped_lock,
sharable_lock etc...
If I use a simple test program that uses mutex like this, I have no problem:
void test1()
{
printf("test1 - timed_lock \n");
printf("trying to get exlusive lock within a timeout of 5 seconds\n");
boost::interprocess::named_mutex
mutex(boost::interprocess::open_or_create, "MyExlusiveTimedMutex");
boost::posix_time::ptime abs_time =
boost::posix_time::second_clock::universal_time() +
boost::posix_time::seconds(5);
if( mutex.timed_lock(abs_time) )
{
printf("mutex acquired! do some processing...\n");
//...do some processing...
printf("unlocking mutex, quit.\n");
mutex.unlock();
}
else
{
printf("mutex not acquired, quit.\n");
}
printf("end of test1\n");
}
This test is ok, it builds with no problem.
Then I try to use the scoped_lock functionalities:
void test2()
{
//open or create the named mutex
printf("creating mutex...\n");
boost::interprocess::named_mutex
n_mutex(boost::interprocess::open_or_create, "ipc_pri_queue_mutex");
{
printf("acquiring mutex scoped_lock...\n");
boost::interprocess::scoped_lockboost::interprocess::named_mutex
sc_lock(n_mutex);
printf("mutex scoped_lock acquired...\n");
//wait some time to simulate execution
printf("execute program...\n");
sleep(10);
printf("program excuted...\n");
}
printf("out of scope, sharable_lock released\n");
}
Also this test is ok, it builds with no problem.
Finally, I try to use the sharable_lock and I get the error:
void test3()
{
//open or create the named upgradable mutex
printf("creating mutex...\n");
boost::interprocess::named_upgradable_mutex
n_u_mutex(boost::interprocess::open_or_create,
"ipc_pri_queue_upgradable_mutex");
{
printf("acquiring mutex sharable_lock...\n");
boost::interprocess::sharable_lockboost::interprocess::named_upgradable_mutex
sh_lock(n_u_mutex);
printf("mutex sharable_lock acquired...\n");
//wait some time to simulate execution
printf("execute program...\n");
sleep(10);
printf("program excuted...\n");
}
printf("out of scope, sharable_lock released\n");
}
If I build this with -O2 optimization flag, I get this error:
g++ -O2 -I /usr/local/boost_1_49_0 -c main.cpp -o main.o
/usr/local/boost_1_49_0/boost/interprocess/detail/atomic.hpp: In member
function 'void
boost::interprocess::ipcdetail::managed_open_or_create_impl
participants (1)
-
Magallo