Modify

Opened 4 years ago

Closed 4 years ago

#8129 closed Bugs (fixed)

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 (3)

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

Download all attachments as: .zip

Change History (7)

Changed 4 years ago by mbradle@…

test cpp file

Changed 4 years ago by mbradle@…

transcript of compilation and warning

Changed 4 years ago by mbradle@…

Change that removed the warning (possible patch)

comment:1 Changed 4 years ago by mbradle@…

  • Version changed from Boost 1.53.0 to Boost Development Trunk

comment:2 follow-up: Changed 4 years 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 4 years 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 4 years ago by joaquin

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

(In [83058]) fixed #8129

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain joaquin.
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.