Boost C++ Libraries: Ticket #8129: Conversion warning in hashed_index.hpp https://svn.boost.org/trac10/ticket/8129 <p> Hello, </p> <p> 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. </p> <p> Brad Meyer </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8129 Trac 1.4.3 mbradle@… Wed, 20 Feb 2013 22:44:14 GMT attachment set https://svn.boost.org/trac10/ticket/8129 https://svn.boost.org/trac10/ticket/8129 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">ex.13.7.cpp</span> </li> </ul> <p> test cpp file </p> Ticket mbradle@… Wed, 20 Feb 2013 22:44:51 GMT attachment set https://svn.boost.org/trac10/ticket/8129 https://svn.boost.org/trac10/ticket/8129 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test.txt</span> </li> </ul> <p> transcript of compilation and warning </p> Ticket mbradle@… Wed, 20 Feb 2013 22:46:31 GMT attachment set https://svn.boost.org/trac10/ticket/8129 https://svn.boost.org/trac10/ticket/8129 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">diff.txt</span> </li> </ul> <p> Change that removed the warning (possible patch) </p> Ticket mbradle@… Wed, 20 Feb 2013 22:51:08 GMT version changed https://svn.boost.org/trac10/ticket/8129#comment:1 https://svn.boost.org/trac10/ticket/8129#comment:1 <ul> <li><strong>version</strong> <span class="trac-field-old">Boost 1.53.0</span> → <span class="trac-field-new">Boost Development Trunk</span> </li> </ul> Ticket Joaquín M López Muñoz Thu, 21 Feb 2013 07:28:11 GMT <link>https://svn.boost.org/trac10/ticket/8129#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8129#comment:2</guid> <description> <p> Hi Brad, </p> <p> Actually, your proposed patch is not entirely correct: <code>n</code> should be promoted to a floating point type, not <code>mlf</code> to integral. Please try the following: </p> <pre class="wiki"> float fbc=static_cast&lt;float&gt;(1+static_cast&lt;double&gt;(n)/mlf); </pre><p> If this clears the warning I'll commit the change to the repository. Thank you. </p> </description> <category>Ticket</category> </item> <item> <author>mbradle@…</author> <pubDate>Thu, 21 Feb 2013 08:26:51 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8129#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8129#comment:3</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/8129#comment:2" title="Comment 2">joaquin</a>: </p> <blockquote class="citation"> <p> Actually, your proposed patch is not entirely correct: <code>n</code> should be promoted to a floating point type, not <code>mlf</code> to integral. Please try the following: </p> <pre class="wiki"> float fbc=static_cast&lt;float&gt;(1+static_cast&lt;double&gt;(n)/mlf); </pre><p> If this clears the warning I'll commit the change to the repository. Thank you. </p> </blockquote> <p> Hi, </p> <p> Yes, this does clear the warning, and I do see that <code>n</code> should be promoted, not <code>mlf</code>. Thanks, and best wishes. </p> <p> Brad </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joaquín M López Muñoz</dc:creator> <pubDate>Thu, 21 Feb 2013 10:11:34 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/8129#comment:4 https://svn.boost.org/trac10/ticket/8129#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/83058" title="fixed #8129">[83058]</a>) fixed <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8129" title="#8129: Bugs: Conversion warning in hashed_index.hpp (closed: fixed)">#8129</a> </p> Ticket