This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 110b. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2023-01-15


551. When is inline permitted in an explicit instantiation?

Section: 13.9.3  [temp.explicit]     Status: CD1     Submitter: Steve Clamage     Date: 07 December 2005

[Voted into the WP at the April, 2007 meeting as part of paper J16/07-0095 = WG21 N2235.]

The Standard does not definitively say when the inline specifier may be used in an explicit instantiation. For example, the following would seem to be innocuous, as the function being instantiated is already inline:

    template <typename T> struct S {
        void f() { }
    };
    template inline void S<int>::f();

However, presumably one would want to prohibit something like:

    template <typename T> void f(T) { }
    template inline void f(int);

9.2.3 [dcl.fct.spec] paragraph 4 (after application of the resolution of issue 317) comes close to covering the obvious problematic cases:

If the definition of a function appears in a translation unit before its first declaration as inline, the program is ill-formed. If a function with external linkage is declared inline in one translation unit, it shall be declared inline in all translation units in which it appears; no diagnostic is required.

This would seem to prohibit the latter case, but apparently would not handle an exported template that was instantiated as inline (because the definition might not appear in the same translation unit as the inline instantiation). It would be better to make a clear statement regarding the use of inline in explicit instantiations.

Notes from the April, 2006 meeting:

The CWG favored completely disallowing the inline keyword in explicit instantiation directives.