Boost logo

Boost :

Subject: Re: [boost] [rational, spirit] 1.68.0 beta 2 bug report
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2018-07-12 02:51:16


AMDG

On 07/11/2018 07:07 PM, James E. King III via Boost wrote:
> A bug reported by someone using a version of 1.68.0 (not specified):
>
> https://github.com/qtumproject/cpp-eth-qtum/issues/31#issuecomment-404257256
>
> Seems to have something to do with the new pow template that was added to
> rational.
> This came from an old pull request that was simplified, however it seems
> pow is now a template defined in the namespace boost, and seems to have
> caused some issues. I'd guess this is only an issue inside boost namespace
> (so all boost headers) and not external namespaces. Not sure at the moment
> if the fix should be in rational or spirit. We could instead back out the
> change to rational for 1.68.0 where pow() was added into namespace boost.
>
> https://github.com/boostorg/rational/pull/21
>

Here's what I think is happening (I can't be certain because
there bug report trims to much of the error message)

- pow is being called with two arguments of integral type.
- std::pow is only overloaded for floating point types.
- The rational overload for pow also matches because
  rational has an implicit constructor.
- The rational pow overload is a better match for
  the second argument (identity conversion), but a
  worse match for the first argument (user-defined
  conversion vs. built-in conversion).

The simplest fix is to overload pow the same way
that the operators are overloaded, using separate
template parameters for the rational value type
and the other integer type. This will prevent
the rational value type from being deduced in
this case.

In Christ,
Steven Watanabe


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk