Boost C++ Libraries: Ticket #5855: narrowing conversion error with -std=c++0x in operator< with int_type != int https://svn.boost.org/trac10/ticket/5855 <p> With GCC (4.6) and -std=c++0x, there are several narrowing conversion errors in operator&lt; if int_type is different from int, for example, short int. Example: #include &lt;boost/rational.hpp&gt; int main() { return boost::rational&lt;short int&gt;() &lt; boost::rational&lt;short int&gt;(); } Error output: /tmp/boost/boost/rational.hpp: In member function ‘bool boost::rational&lt;<a class="missing wiki">IntType</a>&gt;::operator&lt;(const boost::rational&lt;<a class="missing wiki">IntType</a>&gt;&amp;) const [with <a class="missing wiki">IntType</a> = short int]’: /tmp/boost/boost/rational.hpp:393:39: error: narrowing conversion of ‘(((int)((const boost::rational&lt;short int&gt;*)this)-&gt;boost::rational&lt;short int&gt;::num) / ((int)((const boost::rational&lt;short int&gt;*)this)-&gt;boost::rational&lt;short int&gt;::den))’ from ‘int’ to ‘boost::rational&lt;short int&gt;::int_type {aka short int}’ inside { } [-fpermissive] /tmp/boost/boost/rational.hpp:393:39: error: narrowing conversion of ‘(((int)((const boost::rational&lt;short int&gt;*)this)-&gt;boost::rational&lt;short int&gt;::num) % ((int)((const boost::rational&lt;short int&gt;*)this)-&gt;boost::rational&lt;short int&gt;::den))’ from ‘int’ to ‘boost::rational&lt;short int&gt;::int_type {aka short int}’ inside { } [-fpermissive] ... </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5855 Trac 1.4.3 mlang@… Thu, 01 Sep 2011 19:24:49 GMT attachment set https://svn.boost.org/trac10/ticket/5855 https://svn.boost.org/trac10/ticket/5855 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">t.cpp</span> </li> </ul> <p> Test case. Compile with gcc -std=c++0x to trigger </p> Ticket mlang@… Thu, 01 Sep 2011 19:30:56 GMT attachment set https://svn.boost.org/trac10/ticket/5855 https://svn.boost.org/trac10/ticket/5855 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">rational_fix.patch</span> </li> </ul> <p> Proposed fix. </p> Ticket Daryle Walker Wed, 21 Aug 2013 23:24:55 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/5855#comment:1 https://svn.boost.org/trac10/ticket/5855#comment:1 <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/85418" title="Used static_cast to suppress a warning/error about a narrowing ...">[85418]</a>) Used static_cast to suppress a warning/error about a narrowing conversion. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5855" title="#5855: Bugs: narrowing conversion error with -std=c++0x in operator&lt; with int_type ... (closed: fixed)">#5855</a>. </p> Ticket