Boost C++ Libraries: Ticket #10328: is_linked is broken for linear slist https://svn.boost.org/trac10/ticket/10328 <p> The following program should print "Ok" but it print "Arghhhh" </p> <p> This is do to is_linked checking the next pointer which is nullptr for the last element. The example works fine when omitting the ,bi::linear&lt;true&gt; line </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;boost/intrusive/slist.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;iostream&gt;</span><span class="cp"></span> <span class="k">namespace</span> <span class="n">bi</span><span class="o">=</span><span class="n">boost</span><span class="o">::</span><span class="n">intrusive</span><span class="p">;</span> <span class="k">struct</span> <span class="n">my_tag</span> <span class="p">{};</span> <span class="k">typedef</span> <span class="n">bi</span><span class="o">::</span><span class="n">slist_base_hook</span><span class="o">&lt;</span><span class="n">bi</span><span class="o">::</span><span class="n">tag</span><span class="o">&lt;</span><span class="n">my_tag</span><span class="o">&gt;</span><span class="p">,</span> <span class="n">bi</span><span class="o">::</span><span class="n">link_mode</span><span class="o">&lt;</span><span class="n">bi</span><span class="o">::</span><span class="n">safe_link</span><span class="o">&gt;</span> <span class="o">&gt;</span> <span class="n">my_hook</span><span class="p">;</span> <span class="k">struct</span> <span class="nl">my_type</span><span class="p">:</span> <span class="k">public</span> <span class="n">my_hook</span> <span class="p">{</span> <span class="kt">bool</span> <span class="n">is_linked</span><span class="p">()</span> <span class="k">const</span> <span class="p">{</span> <span class="k">return</span> <span class="n">my_hook</span><span class="o">::</span><span class="n">is_linked</span><span class="p">();</span> <span class="p">}</span> <span class="p">};</span> <span class="k">typedef</span> <span class="n">bi</span><span class="o">::</span><span class="n">slist</span><span class="o">&lt;</span><span class="n">my_type</span><span class="p">,</span> <span class="n">bi</span><span class="o">::</span><span class="n">base_hook</span><span class="o">&lt;</span><span class="n">my_hook</span><span class="o">&gt;</span> <span class="p">,</span> <span class="n">bi</span><span class="o">::</span><span class="n">linear</span><span class="o">&lt;</span><span class="nb">true</span><span class="o">&gt;</span> <span class="o">&gt;</span> <span class="n">my_list</span><span class="p">;</span> <span class="kt">int</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span> <span class="n">my_type</span> <span class="n">item</span><span class="p">;</span> <span class="n">my_list</span> <span class="n">list</span><span class="p">;</span> <span class="n">list</span><span class="p">.</span><span class="n">push_front</span><span class="p">(</span><span class="n">item</span><span class="p">);</span> <span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="p">(</span><span class="n">item</span><span class="p">.</span><span class="n">is_linked</span><span class="p">()</span> <span class="o">?</span> <span class="s">&quot;Ok&quot;</span><span class="o">:</span> <span class="s">&quot;Arghhhhh&quot;</span><span class="p">)</span> <span class="o">&lt;&lt;</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span> <span class="p">}</span> </pre></div></div> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10328 Trac 1.4.3 antialize@… Fri, 08 Aug 2014 13:32:50 GMT cc set https://svn.boost.org/trac10/ticket/10328#comment:1 https://svn.boost.org/trac10/ticket/10328#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">antialize@…</span> added </li> </ul> Ticket Ion Gaztañaga Thu, 14 Aug 2014 13:11:49 GMT <link>https://svn.boost.org/trac10/ticket/10328#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10328#comment:2</guid> <description> <p> As the null value is used to mark a node as "unlinked", it's not possible to know if an element is unlinked or it's the last element in null ended (linear) lists. Currently this problem has no solution. The only thing we can do without breaking some code is to document this behaviour. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 14 Aug 2014 13:38:16 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10328#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10328#comment:3</guid> <description> <p> I guess one could change one of the nulls, to be a self pointer (or more ugly a 1) pointer. </p> <p> Ofcause if users read the actual pointer values that nothing can be changed. If that is not the case, then the unlinked status could be the element pointing to it self. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Thu, 04 Aug 2016 21:45:57 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/10328#comment:4 https://svn.boost.org/trac10/ticket/10328#comment:4 <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">wontfix</span> </li> </ul> <p> Reviewing old bugs. Due to ABI issues and the fact that a node pointing to null could be also not linked to anything, the estrange behaviour was documented in commit: </p> <p> <a class="ext-link" href="https://github.com/boostorg/intrusive/commit/5a7892a85913fa811800510b1f7de310c93f44f3"><span class="icon">​</span>https://github.com/boostorg/intrusive/commit/5a7892a85913fa811800510b1f7de310c93f44f3</a> </p> <p> to warn users. Thanks for the report. </p> Ticket