Subject: [Boost-bugs] [Boost C++ Libraries] #6771: unordered_map comparing float in assertion statement causes large warning in gcc
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-04-06 12:05:43
#6771: unordered_map comparing float in assertion statement causes large warning
in gcc
---------------------------------------------------------+------------------
Reporter: Ryan Fogarty <ryan.fogarty.msece@â¦> | Owner: danieljames
Type: Bugs | Status: new
Milestone: To Be Determined | Component: unordered
Version: Boost Release Branch | Severity: Problem
Keywords: |
---------------------------------------------------------+------------------
In unordered/detail/table.hpp an assertion statement in function
std::size_t min_buckets_for_size(std::size_t size) const
compares a floating point which causes deeply nested warning statements in
gcc with some compiler flags (possibly -Wall/-Wfloat-equal/-pedantic)
{{{
BOOST_ASSERT(this->mlf_ != 0);
}}}
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:
{{{
BOOST_ASSERT(this->mlf_ > 0.0f || this->mlf_ < 0.0);
}}}
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.
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]
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/6771> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:09 UTC