Boost logo

Boost :

From: Glen Fernandes (glen.fernandes_at_[hidden])
Date: 2020-11-16 14:43:50


We have a problem with Boost.Rational and <boost/operators.hpp> in
Boost.Utility in C++20 standards mode. I've fixed Boost.Rational in
develop.

Relevant GitHub issues:
1. https://github.com/boostorg/rational/issues/43
2. https://github.com/boostorg/utility/issues/65

My fix for Boost.Rational that I will merge to master for the 1.75
release: https://github.com/boostorg/rational/pull/45

The root cause is the same. C++20 adds new language rules that
implicitly generate some operators, and the current implementations
result in an infinite loop. (In both cases an equality operator ends
up calling itself recursively).

GCC does emit a warning diagnostic in C++20 mode, but as usual these
tend to be unnoticed at build time.

../../boost/rational.hpp:779:16: warning: in C++20 this comparison
calls the current function recursively with reversed arguments
  779 | return a == b;
      | ~~^~~~

So this issue was found by three independent users of Rational (one
who reported a Github issue, the other who complained on Reddit, and a
third that tried running the Rational unit tests with GCC10 and found
two failures).

<boost/operators.hpp> in Boost.Utility still needs a fix for C++20
mode, but it has an active maintainer unlike Rational. The GitHub
issue for it was closed (I've reopened it) because it was assumed to
be a defect in the standard and one that vendors would fix.

We did have some discussion on the C++ standard committee reflector
about this, however - whatever the future change to the standard is -
GCC and Clang with -std=c++20 that implement these rules have already
been released and users are using it, so we should fix this in Boost
1.75.

Glen


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