Opened 11 years ago
Closed 9 years ago
#5855 closed Bugs (fixed)
narrowing conversion error with -std=c++0x in operator< with int_type != int
Reported by: | Owned by: | Jonathan Turkanis | |
---|---|---|---|
Milestone: | To Be Determined | Component: | rational |
Version: | Boost Development Trunk | Severity: | Problem |
Keywords: | Cc: |
Description
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] ...
Attachments (2)
Change History (3)
by , 11 years ago
comment:1 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Test case. Compile with gcc -std=c++0x to trigger