[Boost-bugs] [Boost C++ Libraries] #10029: Member variable vs local variable

Subject: [Boost-bugs] [Boost C++ Libraries] #10029: Member variable vs local variable
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-05-09 09:19:03


#10029: Member variable vs local variable
---------------------------------+--------------------------
 Reporter: Vijay Rao <vijay@…> | Owner: igaztanaga
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: interprocess
  Version: Boost 1.54.0 | Severity: Problem
 Keywords: |
---------------------------------+--------------------------
 I'm hitting a strange compiler error when I define a 'set' as a local
 variable but not when the same set is declared and defined as a member
 variable. This code;

 {{{
 #include <boost/interprocess/managed_shared_memory.hpp>
 #include <boost/interprocess/containers/set.hpp>

 using namespace boost::interprocess;

 struct S
 {
   typedef int Element;
   typedef allocator<Element, managed_shared_memory::segment_manager>
 Allocator;
   typedef set<Element, std::less<Element>, Allocator> Qset;

   S(managed_shared_memory::segment_manager*);
 };

 S::S(managed_shared_memory::segment_manager*man)
 {
   Qset q_instance(std::less<Element>(),
                   Allocator(man));

   q_instance.insert(0);
 }

 S s_instance(0);
 }}}

 doesn't compile, and gives me the following errors with 'g++ (GCC) 4.8.2
 20131212 (Red Hat 4.8.2-7)':

 {{{
 redux.cc: In constructor
 â€˜S::S(boost::interprocess::ipcdetail::basic_managed_memory_impl<char,
 boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>,
 boost::interprocess::iset_index, 16ul>::segment_manager*)’:
 redux.cc:20:14: error: request for member ‘insert’ in ‘q_instance’, which
 is of non-class type ‘S::Qset(std::less<int> (*)(), S::Allocator) {aka
 boost::container::set<int, std::less<int>,
 boost::interprocess::allocator<int,
 boost::interprocess::segment_manager<char,
 boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>,
 boost::interprocess::iset_index> > >(std::less<int> (*)(),
 boost::interprocess::allocator<int,
 boost::interprocess::segment_manager<char,
 boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>,
 boost::interprocess::iset_index> >)}’
    q_instance.insert(0);
               ^
 }}}

 If I however turn 'q_instance' into a member variable as in the following
 code;

 {{{
 #include <boost/interprocess/managed_shared_memory.hpp>
 #include <boost/interprocess/containers/set.hpp>

 using namespace boost::interprocess;

 struct S
 {
   typedef int Element;
   typedef allocator<Element, managed_shared_memory::segment_manager>
 Allocator;
   typedef set<Element, std::less<Element>, Allocator> Qset;

   Qset q_instance;

   S(managed_shared_memory::segment_manager*);
 };

 S::S(managed_shared_memory::segment_manager*man) :
   q_instance(std::less<Element>(),
              Allocator(man))
 {
   q_instance.insert(0);
 }

 S s_instance(0);
 }}}

 then the code compiles without a problem.

 I'm not seeing why the first piece of code should fail to compile.

 boost: 1.54.0-9.fc20

 g++: 4.8.2 20131212 (Red Hat 4.8.2-7)

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10029>
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:16 UTC