Modify

Opened 5 years ago

Closed 5 years ago

#8129 closed Bugs (fixed)

Conversion warning in hashed_index.hpp

Reported by: mbradle@… Owned by: Joaquín M López Muñoz
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@… 5 years ago.
test cpp file
test.txt (16.6 KB) - added by mbradle@… 5 years ago.
transcript of compilation and warning
diff.txt (639 bytes) - added by mbradle@… 5 years ago.
Change that removed the warning (possible patch)

Download all attachments as: .zip

Change History (7)

Changed 5 years ago by mbradle@…

Attachment: ex.13.7.cpp added

test cpp file

Changed 5 years ago by mbradle@…

Attachment: test.txt added

transcript of compilation and warning

Changed 5 years ago by mbradle@…

Attachment: diff.txt added

Change that removed the warning (possible patch)

comment:1 Changed 5 years ago by mbradle@…

Version: Boost 1.53.0Boost Development Trunk

comment:2 Changed 5 years ago by Joaquín M López Muñoz

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 5 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 5 years ago by Joaquín M López Muñoz

Resolution: fixed
Status: newclosed

(In [83058]) fixed #8129

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Joaquín M López Muñoz.
The resolution will be deleted.

Add Comment


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

 
Note: See TracTickets for help on using tickets.