Issue 182232
Summary libc++: Nested variant compilation issue on use of `operator==` in C++23 mode
Labels libc++
Assignees
Reporter devgs
    Here's a simplified test case.

```
#include <vector>
#include <variant>

struct Array;

struct A1 { auto operator<=>(const A1 &) const = default; };
struct A2 { auto operator<=>(const A2 &) const = default; };

using Var1 = 
        std::variant<
            A1
            , Array
            >;

struct Array : public std::vector<Var1>
{
 using vector::vector;
};

// This fails
using Var2 =
 std::variant<
            A2
            , Array
 >;

static_assert(std::equality_comparable<Var2>);

int main()
{
 constexpr bool foo = Var2{} == Var2{};
    return 0;
}
```

And here's a [demo on godbolt.com](https://godbolt.org/z/nWfenv9ej).

And here's the link to related [stackoverflow.com question](https://stackoverflow.com/questions/79891776/weird-stdvariantoperator-error-with-clang-libc-and-specific-number-o).

As can be seen, `std::equality_comparable<Var2>` produces true but the actual compilation fails. Problem exists only with **clang** + **libc++** combo. Thanks to **T.C.**'s observation it seems to stem from the fact that, in both variants, `Array` shares the same *alternative index*. This helped to simplify the original test case.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to