Opened 13 years ago

Closed 12 years ago

#4139 closed Bugs (fixed)

gcd_integer in common_factor_rt.hpp fails to compile for some IntegerTypes (like mpz_class)

Reported by: mitchnull@… Owned by: John Maddock
Milestone: To Be Determined Component: math
Version: Boost Development Trunk Severity: Problem
Keywords: gcd_integer Cc:

Description

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;

}

Change History (1)

comment:1 by John Maddock, 12 years ago

Resolution: fixed
Status: newclosed

(In [61837]) Fix failures when used with an expression-template enabled number type such as the gmpxx clases. Add additional concept check for integer code using gmp classes. Fixes #4139.

Note: See TracTickets for help on using tickets.