Subject: [Boost-bugs] [Boost C++ Libraries] #4139: gcd_integer in common_factor_rt.hpp fails to compile for some IntegerTypes (like mpz_class)
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-04-22 14:58:08
#4139: gcd_integer in common_factor_rt.hpp fails to compile for some IntegerTypes
(like mpz_class)
-------------------------------------+--------------------------------------
Reporter: mitchnull@⦠| Owner: johnmaddock
Type: Bugs | Status: new
Milestone: To Be Determined | Component: math
Version: Boost Development Trunk | Severity: Problem
Keywords: gcd_integer |
-------------------------------------+--------------------------------------
The use of the ternary operator in gcd_integer in common_factor_rt.hpp:119
can lead to compile time error if the unary operator- of the given type
doesn't return the same type as itself:
return ( result < zero ) ? -result : result;
as the type of "-result" and "result" differs.
Either a static_cast is needed like:
return ( result < zero ) ? static_cast<IntegerType>(-result) : result;
or the one-liner should be replaced with an if like this:
if ( result < zero )
{
return -result;
}
else
{
return result;
}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/4139> 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:02 UTC