Boost C++ Libraries: Ticket #6771: unordered_map comparing float in assertion statement causes large warning in gcc https://svn.boost.org/trac10/ticket/6771 <p> In unordered/detail/table.hpp an assertion statement in function </p> <p> std::size_t min_buckets_for_size(std::size_t size) const </p> <p> compares a floating point which causes deeply nested warning statements in gcc with some compiler flags (possibly -Wall/-Wfloat-equal/-pedantic) </p> <pre class="wiki"> BOOST_ASSERT(this-&gt;mlf_ != 0); </pre><p> Because of the nature of the template code the warning is very difficult to read and it is not obvious whether it is a problem in user's code or the library (from a quick glance). A simple alternative eliminates the issue: </p> <pre class="wiki"> BOOST_ASSERT(this-&gt;mlf_ &gt; 0.0f || this-&gt;mlf_ &lt; 0.0); </pre><p> Bug has existed for quite a while. It is at least as old as 1.46, and I've confirmed that exists in 1.47 (line:138) - 1.49 (line:387) and is also on the trunk. </p> <p> As an example The warning in gcc 4.7.0 ends with: /usr/local/boost_1_49_0/include/boost/unordered/detail/table.hpp:387:13: warning: comparing floating point with == or != is unsafe [-Wfloat-equal] </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6771 Trac 1.4.3 Daniel James Sun, 08 Apr 2012 15:29:22 GMT <link>https://svn.boost.org/trac10/ticket/6771#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6771#comment:1</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/77832" title="Unordered/hash: Avoid a gcc warning. Refs #6771">[77832]</a>) Unordered/hash: Avoid a gcc warning. Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6771" title="#6771: Bugs: unordered_map comparing float in assertion statement causes large ... (closed: fixed)">#6771</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Daniel James</dc:creator> <pubDate>Sun, 06 May 2012 12:32:11 GMT</pubDate> <title>status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/6771#comment:2 https://svn.boost.org/trac10/ticket/6771#comment:2 <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.50.0</span> </li> </ul> <p> Merged to release in <a class="changeset" href="https://svn.boost.org/trac10/changeset/78319" title="Unordered/Hash: Merge from trunk. ">[78319]</a> </p> Ticket