Boost C++ Libraries: Ticket #10510: boost::uuids::uuid comparison error when used as key in std::map https://svn.boost.org/trac10/ticket/10510 <p> When using two almost equal uuids (e.g. the last character differs), <em>a</em> as a key of a std::map and <em>b</em> as parameter for the <strong>find</strong> function, the function will return that elements <em>b</em> is found in the map. </p> <p> A simple test to reproduce the bug: </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;map&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;iostream&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/uuid/uuid.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/uuid/string_generator.hpp&gt;</span><span class="cp"></span> <span class="kt">int</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span> <span class="n">boost</span><span class="o">::</span><span class="n">uuids</span><span class="o">::</span><span class="n">string_generator</span> <span class="n">gen</span><span class="p">;</span> <span class="n">boost</span><span class="o">::</span><span class="n">uuids</span><span class="o">::</span><span class="n">uuid</span> <span class="n">a</span> <span class="o">=</span> <span class="n">gen</span><span class="p">(</span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="p">(</span><span class="s">&quot;145cfc95-8050-455a-8382-44ca57c1483b&quot;</span><span class="p">));</span> <span class="n">boost</span><span class="o">::</span><span class="n">uuids</span><span class="o">::</span><span class="n">uuid</span> <span class="n">b</span> <span class="o">=</span> <span class="n">gen</span><span class="p">(</span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="p">(</span><span class="s">&quot;145cfc95-8050-455a-8382-44ca57c1483c&quot;</span><span class="p">));</span> <span class="n">std</span><span class="o">::</span><span class="n">map</span><span class="o">&lt;</span><span class="n">boost</span><span class="o">::</span><span class="n">uuids</span><span class="o">::</span><span class="n">uuid</span><span class="p">,</span> <span class="kt">int</span><span class="o">&gt;</span> <span class="n">elements</span><span class="p">;</span> <span class="c1">// Adding element &#39;a&#39;</span> <span class="n">elements</span><span class="p">.</span><span class="n">insert</span><span class="p">(</span><span class="n">std</span><span class="o">::</span><span class="n">make_pair</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="mi">1</span><span class="p">));</span> <span class="c1">// Element &#39;b&#39; is found although is not added.</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">elements</span><span class="p">.</span><span class="n">find</span><span class="p">(</span><span class="n">b</span><span class="p">)</span> <span class="o">!=</span> <span class="n">elements</span><span class="p">.</span><span class="n">end</span><span class="p">())</span> <span class="o">?</span> <span class="s">&quot;Found.&quot;</span> <span class="o">:</span> <span class="s">&quot;Not found.&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="k">return</span> <span class="mi">0</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/10510 Trac 1.4.3 hvemha@… Tue, 30 Sep 2014 20:30:55 GMT <link>https://svn.boost.org/trac10/ticket/10510#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10510#comment:1</guid> <description> <p> This is a regression in 1.56.0 (the SIMD optimization of operator&lt;). As a fix you can disable the optimization (define BOOST_UUID_NO_SIMD) </p> <p> You can also have a look on this pull request: <a class="ext-link" href="https://github.com/boostorg/uuid/pull/5"><span class="icon">​</span>https://github.com/boostorg/uuid/pull/5</a> </p> </description> <category>Ticket</category> </item> <item> <author>a.gronchi@…</author> <pubDate>Wed, 27 May 2015 15:24:30 GMT</pubDate> <title>version changed https://svn.boost.org/trac10/ticket/10510#comment:2 https://svn.boost.org/trac10/ticket/10510#comment:2 <ul> <li><strong>version</strong> <span class="trac-field-old">Boost 1.56.0</span> → <span class="trac-field-new">Boost 1.57.0</span> </li> </ul> <p> Bumping the ticket. </p> <p> This is verified on 1.57.0, gcc version 4.9.2 (GCC), on Linux x86_64. The suggested workaround managed to get uuid::operator&lt;() work correctly. </p> Ticket cosmin.szanto Thu, 28 May 2015 05:58:30 GMT <link>https://svn.boost.org/trac10/ticket/10510#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10510#comment:3</guid> <description> <p> The bug is still reproducible with 1.58 and GCC version 5.1.0 on Linux x86_64. </p> </description> <category>Ticket</category> </item> <item> <author>Jonathan Wakely <jwakely.boost@…></author> <pubDate>Fri, 21 Aug 2015 15:53:31 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10510#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10510#comment:4</guid> <description> <p> This is fixed in 1.59.0 </p> </description> <category>Ticket</category> </item> <item> <author>James E. King, III <jking@…></author> <pubDate>Fri, 04 Aug 2017 13:16:56 GMT</pubDate> <title>version changed https://svn.boost.org/trac10/ticket/10510#comment:5 https://svn.boost.org/trac10/ticket/10510#comment:5 <ul> <li><strong>version</strong> <span class="trac-field-old">Boost 1.57.0</span> → <span class="trac-field-new">Boost 1.56.0</span> </li> </ul> <p> I cannot edit this defect and set the milestone to 1.59.0 - the earliest I could set it to is 1.61.0. Perhaps someone else can set it to the right thing and close it, once verified. Given it was seen first in 1.56.0 I changed the version field back to that. </p> Ticket Michael Caisse Sat, 12 Aug 2017 23:34:13 GMT status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/10510#comment:6 https://svn.boost.org/trac10/ticket/10510#comment:6 <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> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.59.0</span> </li> </ul> Ticket