Opened 10 years ago

Closed 10 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@… 10 years ago.
test cpp file
test.txt (16.6 KB ) - added by mbradle@… 10 years ago.
transcript of compilation and warning
diff.txt (639 bytes ) - added by mbradle@… 10 years ago.
Change that removed the warning (possible patch)

Download all attachments as: .zip

Change History (7)

by mbradle@…, 10 years ago

Attachment: ex.13.7.cpp added

test cpp file

by mbradle@…, 10 years ago

Attachment: test.txt added

transcript of compilation and warning

by mbradle@…, 10 years ago

Attachment: diff.txt added

Change that removed the warning (possible patch)

comment:1 by mbradle@…, 10 years ago

Version: Boost 1.53.0Boost Development Trunk

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

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.

in reply to:  2 comment:3 by mbradle@…, 10 years ago

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

Resolution: fixed
Status: newclosed

(In [83058]) fixed #8129

Note: See TracTickets for help on using tickets.