Boost C++ Libraries: Ticket #3417: boost::interprocess::managed_shared_memory::belongs_to_segment returns incorrect value. https://svn.boost.org/trac10/ticket/3417 <p> Hello, </p> <p> It seems that boost::interprocess::managed_shared_memory::belongs_to_segment implementation is not correct. It returns true for chunks of memory that don't belong to the shared memory segment providing it's lying at a higher address. </p> <p> Looking at <a class="ext-link" href="https://svn.boost.org/trac/boost/browser/trunk/boost/interprocess/detail/managed_memory_impl.hpp"><span class="icon">​</span>https://svn.boost.org/trac/boost/browser/trunk/boost/interprocess/detail/managed_memory_impl.hpp</a> shows: </p> <p> 262 </p> <blockquote> <p> <em>!Returns true if the address belongs to the managed memory segment </em></p> </blockquote> <blockquote> <p> 263 </p> <blockquote> <p> bool belongs_to_segment (const void *ptr) const </p> </blockquote> <p> 264 </p> <blockquote> <p> { </p> </blockquote> <p> 265 </p> <blockquote> <blockquote> <p> return ptr &gt;= this-&gt;get_address() &amp;&amp; </p> </blockquote> </blockquote> <p> 266 </p> <blockquote> <blockquote> <blockquote> <p> ptr &lt; (reinterpret_cast&lt;const char*&gt;(ptr) + this-&gt;get_size()); </p> </blockquote> </blockquote> </blockquote> <p> 267 </p> <blockquote> <p> } </p> </blockquote> </blockquote> <p> It would be more logical to have: </p> <blockquote> <p> <em>!Returns true if the address belongs to the managed memory segment bool belongs_to_segment (const void *ptr) const { </em></p> <blockquote> <p> return ptr &gt;= this-&gt;get_address() &amp;&amp; </p> <blockquote> <p> ptr &lt; (reinterpret_cast&lt;const char *&gt;(this-&gt;get_address()) + this-&gt;get_size()); </p> </blockquote> </blockquote> <p> } </p> </blockquote> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3417 Trac 1.4.3 Lénaïc Huard <lhuard@…> Sat, 20 Feb 2010 16:31:59 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3417#comment:1 https://svn.boost.org/trac10/ticket/3417#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Implemented in 1.41. </p> Ticket