[Boost-bugs] [Boost C++ Libraries] #7118: Condition.Wait with a mutex instead of lock can be mysterious

Subject: [Boost-bugs] [Boost C++ Libraries] #7118: Condition.Wait with a mutex instead of lock can be mysterious
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-07-11 16:39:54


#7118: Condition.Wait with a mutex instead of lock can be mysterious
----------------------------------------------------------+-----------------
 Reporter: Trey Van Riper <fleeb.fantastique@…> | Owner: igaztanaga
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: interprocess
  Version: Boost 1.51.0 | Severity: Cosmetic
 Keywords: |
----------------------------------------------------------+-----------------
 This code correctly fails to compile:
 #include <boost/interprocess/sync/named_condition.hpp>
 #include <boost/interprocess/sync/named_mutex.hpp>


 int _tmain(int argc, _TCHAR* argv[])
 {
         boost::interprocess::named_mutex mutex(
 boost::interprocess::open_or_create, "test" );
         boost::interprocess::named_condition condition(
 boost::interprocess::open_or_create, "test" );
         condition.wait( mutex );
         return 0;
 }

 The resulting compile error (at least on VC++ 2010) is a tad mysterious:

 1>c:\code\sdks\boost\include\boost-
 1_50\boost\interprocess\sync\shm\named_condition.hpp(204): error C2248:
 'boost::interprocess::interprocess_mutex::mutex' : cannot access private
 member declared in class 'boost::interprocess::interprocess_mutex'
 1> c:\code\sdks\boost\include\boost-
 1_50\boost\interprocess\sync\interprocess_mutex.hpp(117) : see declaration
 of 'boost::interprocess::interprocess_mutex::mutex'
 1> c:\code\sdks\boost\include\boost-
 1_50\boost\interprocess\sync\interprocess_mutex.hpp(67) : see declaration
 of 'boost::interprocess::interprocess_mutex'
 1> c:\code\sdks\boost\include\boost-
 1_50\boost\interprocess\sync\shm\named_condition.hpp(204) : while
 compiling class template member function
 'boost::interprocess::ipcdetail::shm_named_condition::lock_wrapper<Lock>::mutex_type
 *boost::interprocess::ipcdetail::shm_named_condition::lock_wrapper<Lock>::mutex(void)
 const'
 1> with
 1> [
 1> Lock=boost::interprocess::named_mutex
 1> ]
 1> c:\code\sdks\boost\include\boost-
 1_50\boost\interprocess\sync\shm\named_condition.hpp(342) : see reference
 to class template instantiation
 'boost::interprocess::ipcdetail::shm_named_condition::lock_wrapper<Lock>'
 being compiled
 1> with
 1> [
 1> Lock=boost::interprocess::named_mutex
 1> ]
 1> c:\code\sdks\boost\include\boost-
 1_50\boost\interprocess\sync\named_condition.hpp(156) : see reference to
 function template instantiation 'void
 boost::interprocess::ipcdetail::shm_named_condition::wait<L>(L &)' being
 compiled
 1> with
 1> [
 1> L=boost::interprocess::named_mutex
 1> ]
 1>
 c:\code\projects\testinterprocess\testinterprocess\testinterprocess.cpp(10)
 : see reference to function template instantiation 'void
 boost::interprocess::named_condition::wait<boost::interprocess::named_mutex>(L
 &)' being compiled
 1> with
 1> [
 1> L=boost::interprocess::named_mutex
 1> ]
 1>c:\code\sdks\boost\include\boost-
 1_50\boost\interprocess\sync\shm\named_condition.hpp(204): error C2064:
 term does not evaluate to a function taking 0 arguments

 It is not obvious that the problem involves the use of a Mutex instead of
 a ScopedLock or the like. While the example code makes this clear, if you
 examine only the documentation, this detail might be confusing.

 Recommend adding a concept check to help guide someone towards using a
 lock instead of a mutex.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7118>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:10 UTC