[cfe-dev] Issue 11851

Andrew Sutton asutton.list at gmail.com
Wed Mar 21 06:51:13 PDT 2012


Has there been discussion about this issue, related to the
instantiation of constexpr functions?

http://llvm.org/bugs/show_bug.cgi?id=11851

I updated yesterday and it still seems to be a problem. This is how
I've reproduced it -- at least, I hope this is the same problem.

template <typename T>
  constexpr bool Type() { return true; }

template <typename T, bool = Type<T>()>
  void f(T x) { }

int main() { f(3); }

Digging through the compiler, it looks like Type<int>() is not being
evaluated as a constant expression because the function definition
hasn't been instantiated by the time the call to f is overloaded. That
would jive with Jeffrey's (on the bug report) explanation of
un-commenting a statement that results instantiation of the function
template prior to its use in overload resolution.

I was going to try to fix this problem, but I'm not sure where to
start. What's the right way to ensure that the definition of an
instantiated template is available in this context i.e., not deferred?

Andrew



More information about the cfe-dev mailing list