The following code compiles with gcc and MSVC, but does not work using clang I, verified with clang-3.5 and the current trunk).
template <typename T> constexpr auto wrong = false; template <typename T> constexpr auto foo(const T t) -> int { static_assert(wrong<T>, ""); return {}; } using F = decltype(foo(1)); int main() {}
clang creates an instance of the function body and stumbles upon static_assert . gcc and MSVC just look at the function declaration and ignore static_assert in the body.
If you remove constexpr, all compilers will compile the code just fine.
Question:
Is decltype allowed to view function body if return type is declared?
I am looking for a link to the corresponding section in the standard.
c ++ gcc language-lawyer clang
Rumburak
source share