[Boost-bugs] [Boost C++ Libraries] #5855: narrowing conversion error with -std=c++0x in operator< with int_type != int

Subject: [Boost-bugs] [Boost C++ Libraries] #5855: narrowing conversion error with -std=c++0x in operator< with int_type != int
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-09-01 19:23:22


#5855: narrowing conversion error with -std=c++0x in operator< with int_type !=
int
-------------------------------------+--------------------------------------
 Reporter: mlang@… | Owner: turkanis
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: rational
  Version: Boost Development Trunk | Severity: Problem
 Keywords: |
-------------------------------------+--------------------------------------
 With GCC (4.6) and -std=c++0x, there are several narrowing conversion
 errors in operator<
 if int_type is different from int, for example, short int.
 Example:
 #include <boost/rational.hpp>
 int main() { return boost::rational<short int>() < boost::rational<short
 int>(); }
 Error output:
 /tmp/boost/boost/rational.hpp: In member function ‘bool
 boost::rational<IntType>::operator<(const boost::rational<IntType>&) const
 [with IntType = short int]’:
 /tmp/boost/boost/rational.hpp:393:39: error: narrowing conversion of
 â€˜(((int)((const boost::rational<short int>*)this)->boost::rational<short
 int>::num) / ((int)((const boost::rational<short
 int>*)this)->boost::rational<short int>::den))’ from ‘int’ to
 â€˜boost::rational<short int>::int_type {aka short int}’ inside { }
 [-fpermissive]
 /tmp/boost/boost/rational.hpp:393:39: error: narrowing conversion of
 â€˜(((int)((const boost::rational<short int>*)this)->boost::rational<short
 int>::num) % ((int)((const boost::rational<short
 int>*)this)->boost::rational<short int>::den))’ from ‘int’ to
 â€˜boost::rational<short int>::int_type {aka short int}’ inside { }
 [-fpermissive]
 ...

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5855>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:07 UTC