Is decltype (foo (1)) allowed to view the body of foo if a return type is declared?

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.

+7
c ++ gcc language-lawyer clang
source share

No one has answered this question yet.

See related questions:

eighteen
creating a template with a constexpr function error
10
Is it possible to create patterns using the for loop in constexpr C ++ 14 function?
10
Why can't a lambda be used in the context of constexpr when it is used to indicate a function?
5
using the result of the constexpr function as a template parameter (clang vs gcc)
4
How to define a static member of a constexpr array to specialize a template class
4
Constexpr error in clang but not in gcc?
3
Constexpr member function in class template
2
instantiating a template with multiple pattern overlay
one
Can the templates function return the type dependent on the same function template of the return type recursively?
one
Remove constexpr from specialized specialization C ++ 14?

All Articles