2

Reproducible code as below or on godbolt compiles with clang trunk and MSVC but fails with gcc trunk. Given that non-template friend function of a template class could be constrained by requires clause, is it a gcc bug here?

template< typename Derived >
struct base {
    friend void foo(Derived const& d) requires requires { bar(d); } {
        bar(d);
    }
};

namespace adl {
    struct S: base<S> {
        friend void bar(S const&) {}
    };
}
using adl::S;

void test(S const& s) {
    foo(s); // gcc error: 'foo' was not declared in this scope
}
wanghan02
  • 1,227
  • 7
  • 14

0 Answers0