https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111004
Bug ID: 111004 Summary: Visitor and concept error message Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: deco33000 at yandex dot com Target Milestone: --- The error code for the following situation is not clear. The error is that struct A and B don't have a "bool activated;" member. The issue is the variant does not reflect what the error is in an helpful way. To ease your life, here is the godbolt: https://godbolt.org/z/Wdr4zn5E1 Do you think it is possible to improve the diagnostic? --------------------------- Reduced test case: #include <iostream> #include <variant> #include <vector> using namespace std; template <class T> concept My_concept = requires(T a) { { a.activated } -> std::same_as<bool &>; }; struct A { bool not_activated; }; struct B { bool not_activated; int other; }; auto test(variant<A, B> &v) -> void { std::visit([](My_concept auto &&arg) { std::cout << "OK\n"; }, v); } int main() { variant<A, B> v; v = A(); test(v); return 0; } ------------------------ Thanks