Open nyanpasu64 opened 3 years ago
Good news: on your test cases, Clang's behavior almost entirely matches GCC's now. https://godbolt.org/z/c7Psxvcr8
The one remaining difference is when you use a requires-clause outside of any template, and the required expression is something ambiguous or overloaded, e.g.: https://godbolt.org/z/zW3r5eaah
void f();
void f(int);
static_assert(requires{ f; }); // Clang+MSVC accept; GCC hard-errors
struct S {
void mf() {
static_assert(requires{ mf; }); // Clang+MSVC accept; GCC hard-errors
static_assert(requires{ S::mf; }); // Clang+MSVC accept; GCC hard-errors
}
};
I'm inclined to think GCC is right, because every compiler agrees that an egregiously ill-formed expression like static_assert(!requires{ "x"*1; });
should produce a hard error, not a quiet false.
Extended Description
If I define a class with a
void member_fn()
which containsrequires{ member_fn; }
, it evaluates to true on Clang but is an error on GCC, despitemember_fn;
being an error on both compilers.If I define a
template<typename T> Class : T
instantiated with aT
containingbase_fn()
, andClass
contains a member function withrequires{ T::base_fn; }
, it evaluates to true on Clang but false on GCC, despitebase_fn;
being an error on both compilers.Is this a Clang bug, or is my code ill-formed? I was using the value of
requires{}
as an input toif constexpr
orstatic_assert
, rather than as a concept or template bound; is this allowed?I've attached a file testing whether
requires{}
in various positions is true, false, or an error to evaluate.