Is the compilation of this code standard behaviour?

Viewed 103

Consider the following code:

struct Undefined;

template <typename T>
void TemplateFunction()
{
  Undefined obj;
}

int main()
{
  return 0;
}

I was always under the impression that template functions and template methods (or methods part of a template class) will only be checked for syntax (unless they are instantiated) in which case the above code should compile.

Problem is, it does not compile with Xcode (ver: 4.3.2, using the LLVM compiler) and now I am wondering whether the above code is non-standard i.e. it should not compile on a compiler conforming to the C++03 standard? The error from Xcode is:

Variable has incomplete type "Undefined"

Note that in the original code, the undefined object is part of the static assertion.

1 Answers
Related