[rational, spirit] 1.68.0 beta 2 bug report

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[rational, spirit] 1.68.0 beta 2 bug report

Boost - Dev mailing list
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

- Jim

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [rational, spirit] 1.68.0 beta 2 bug report

Boost - Dev mailing list
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

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost