https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99846

--- Comment #8 from Nils Gladitz <nilsgladitz at gmail dot com> ---
(In reply to Jonathan Wakely from comment #5)
> Now this is *obviously* wrong. The left < right expression uses the
> operator< defined for the std::list<Value> base class, which depends on
> comparing the list's elements, which obviously recurses.

Maybe my original test case was reduced a bit too far.
Recursive but bounded example which maybe is a little closer to the original
case and I hope maybe a little less obviously wrong:

#include <list>
#include <iostream>
#include <variant>

struct Value;

using Array = std::list<Value>;
using Variant = std::variant<int, Array>;

struct Value : Variant
{
    using Variant::variant;
};

int main()
{
    Value left = Array{2, Array{}, 3};
    Value right = Array{1};

    std::cout << "<\t" << (left < right) << std::endl;
    std::cout << ">\t" << (left > right) << std::endl;
    std::cout << "==\t" << (left == right) << std::endl;
}

Reply via email to