Modify

Ticket #6771 (closed Bugs: fixed)

Opened 2 years ago

Last modified 2 years ago

unordered_map comparing float in assertion statement causes large warning in gcc

Reported by: Ryan Fogarty <ryan.fogarty.msece@…> Owned by: danieljames
Milestone: Boost 1.50.0 Component: unordered
Version: Boost Release Branch Severity: Problem
Keywords: Cc:

Description

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]

Attachments

Change History

comment:1 Changed 2 years ago by danieljames

(In [77832]) Unordered/hash: Avoid a gcc warning. Refs #6771

comment:2 Changed 2 years ago by danieljames

  • Status changed from new to closed
  • Resolution set to fixed
  • Milestone changed from To Be Determined to Boost 1.50.0

Merged to release in [78319]

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.