[release] Fixing Boost.Rational and boost/operators.hpp infinite loop in C++20 by 1.75

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

[release] Fixing Boost.Rational and boost/operators.hpp infinite loop in C++20 by 1.75

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

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

Re: [release] Fixing Boost.Rational and boost/operators.hpp infinite loop in C++20 by 1.75

Boost - Dev mailing list
On Mon, Nov 16, 2020 at 6:44 AM Glen Fernandes via Boost
<[hidden email]> wrote:
> GCC does emit a warning diagnostic in C++20 mode, but as usual these
> tend to be unnoticed at build time.

Boost.JSON CI scripts set warnings as errors for this reason.

Thanks

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