-
Notifications
You must be signed in to change notification settings - Fork 72
Description
#include <boost/operators.hpp>
struct my_type : boost::equality_comparable2<my_type, double> {
explicit my_type(double mem) : mem_{mem}{}
double mem_{0};
operator double() {
return mem_;
}
bool operator==(my_type l) {
return l.mem_ == mem_;
}
};
int main() {
my_type x{0};
return x == double{0};
}
expected: return 1
actual: infinite loop
this minimum example is based on the implementation of BOOST_STRONG_TYPEDEF in the boost serialization library. I originally opened an issue in the serialization library boostorg/serialization#201 although it seems that the problem can be further narrowed down to equality_comparable2
the issue only seems to happen on clang10, clang trunk, and gcc trunk with std=c++2a or std=c++20 flag. clang10 and company produce the expected result when passed the std=c++17 flag instead of 2a. other versions (gcc9 and clang9) produce the expected result even with the std=c++2a flag. I tried with boost 1.72 and 1.73 and they both produce the same behavior. as an additional note, the optimization level does seem to affect the behavior.
let me know if any additional info is required. thank you!