https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113830

--- Comment #11 from Bo Wang <wangbopku15 at gmail dot com> ---
(In reply to Jakub Jelinek from comment #10)
> But again, T::unknown isn't used except in a template which is not
> instantiated.
> It can't be checked during parsing because T::unknown is dependent and could
> very well be well formed if it was instantiated with a different template
> argument.
> So, does the standard require that all methods of local classes are
> instantiated when the containing function template is instantiate (of
> course, that can't be the case for methods which are templates on their own)?

Thank you for pointing out the critical point.

I have read the working draft standard of C++20
(https://github.com/cplusplus/draft/tree/c%2B%2B20).

Following the subsection "13.9.2 Explicit instantiation" in the section "13.9
Template instantiation and specialization", the statement `template void
f<int>();` is an explicit instantiation, which requires instantiating
everything in the function.

So we don't need another explicit function call to instantiate it.

If my understanding of the standard is correct, the compiler indeed should
instantiate and reject this code.

Reply via email to