Consider the following code. I can compile it with GCC 10.2.0 and Clang 11.0.0 (as expected):
#include <iostream>
template<int>
struct T {
static constexpr auto fun() noexcept { return 0; }
using type = std::remove_cvref_t<decltype(fun())>;
};
int main() {
decltype(T<1>::fun()) a = 1;
std::cout << a;
}
If I replace constexpr
with consteval
, then Clang complains about std::remove_cvref_t<decltype(fun())>
:
error: cannot take address of consteval function 'fun' outside of an immediate invocation
GCC compile it just fine. Why?