Modify

Ticket #8129 (closed Bugs: fixed)

Opened 14 months ago

Last modified 14 months ago

Conversion warning in hashed_index.hpp

Reported by: mbradle@… Owned by: joaquin
Milestone: To Be Determined Component: multi_index
Version: Boost Development Trunk Severity: Cosmetic
Keywords: Cc:

Description

Hello,

I get a warning that conversion to 'float' from 'size_type' may alter its value when compiling the code ex.13.7.cpp (based on an example from The Boost C++ Libraries by Boris Schaeling) with -Wconversion. The attached file test.txt shows the compilation. The attached file diff.txt shows a change that fixed the problem for me. Thanks, and best wishes.

Brad Meyer

Attachments

ex.13.7.cpp Download (1.1 KB) - added by mbradle@… 14 months ago.
test cpp file
test.txt Download (16.6 KB) - added by mbradle@… 14 months ago.
transcript of compilation and warning
diff.txt Download (639 bytes) - added by mbradle@… 14 months ago.
Change that removed the warning (possible patch)

Change History

Changed 14 months ago by mbradle@…

test cpp file

Changed 14 months ago by mbradle@…

transcript of compilation and warning

Changed 14 months ago by mbradle@…

Change that removed the warning (possible patch)

comment:1 Changed 14 months ago by mbradle@…

  • Version changed from Boost 1.53.0 to Boost Development Trunk

comment:2 follow-up: ↓ 3 Changed 14 months ago by joaquin

Hi Brad,

Actually, your proposed patch is not entirely correct: n should be promoted to a floating point type, not mlf to integral. Please try the following:

      float     fbc=static_cast<float>(1+static_cast<double>(n)/mlf);

If this clears the warning I'll commit the change to the repository. Thank you.

comment:3 in reply to: ↑ 2 Changed 14 months ago by mbradle@…

Replying to joaquin:

Actually, your proposed patch is not entirely correct: n should be promoted to a floating point type, not mlf to integral. Please try the following:

      float     fbc=static_cast<float>(1+static_cast<double>(n)/mlf);

If this clears the warning I'll commit the change to the repository. Thank you.

Hi,

Yes, this does clear the warning, and I do see that n should be promoted, not mlf. Thanks, and best wishes.

Brad

comment:4 Changed 14 months ago by joaquin

  • Status changed from new to closed
  • Resolution set to fixed

(In [83058]) fixed #8129

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.