Boost C++ Libraries: Ticket #11751: variant of non-const references fails equality compare https://svn.boost.org/trac10/ticket/11751 <p> The following aborts: </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;boost/variant.hpp&gt;</span><span class="cp"></span> <span class="k">using</span> <span class="n">variant_type</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">variant</span><span class="o">&lt;</span> <span class="kt">int</span><span class="o">&amp;</span> <span class="o">&gt;</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="kt">int</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">;</span> <span class="n">variant_type</span> <span class="n">v</span> <span class="p">(</span><span class="n">a</span><span class="p">),</span> <span class="n">u</span> <span class="p">(</span><span class="n">b</span><span class="p">);</span> <span class="n">v</span> <span class="o">==</span> <span class="n">u</span><span class="p">;</span> <span class="k">return</span> <span class="mi">0</span><span class="p">;</span> <span class="p">}</span> </pre></div></div><p> Compile and run: </p> <pre class="wiki">$ g++ -std=c++14 -I/opt/boost/default/include t.cpp &amp;&amp; ./a.out a.out: /opt/boost/default/include/boost/variant/detail/forced_return.hpp:39: T boost::detail::variant::forced_return() [with T = const int&amp;]: Assertion `false' failed. Aborted (core dumped) </pre><p> It seems that the cause is the instantiation of known_get for const T at line 905 in variant.hpp (1.59.0). </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11751 Trac 1.4.3 anonymous Sat, 24 Oct 2015 12:59:24 GMT component changed; owner set https://svn.boost.org/trac10/ticket/11751#comment:1 https://svn.boost.org/trac10/ticket/11751#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">ebf</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">variant</span> </li> </ul> Ticket Antony Polukhin Fri, 27 May 2016 22:34:21 GMT owner, status, milestone changed https://svn.boost.org/trac10/ticket/11751#comment:2 https://svn.boost.org/trac10/ticket/11751#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">ebf</span> to <span class="trac-author">Antony Polukhin</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.62.0</span> </li> </ul> Ticket Antony Polukhin Fri, 27 May 2016 22:36:00 GMT <link>https://svn.boost.org/trac10/ticket/11751#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11751#comment:3</guid> <description> <p> Fixed in <a class="ext-link" href="https://github.com/boostorg/variant/commit/082732aad80206bf74a4f05767699f156cd7382c"><span class="icon">​</span>082732aa develop</a>, will be merged to master as soon as the tests will cycle. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Sat, 29 Oct 2016 18:10:27 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/11751#comment:4 https://svn.boost.org/trac10/ticket/11751#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket