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

2024-10-26


2916. Variable template partial specializations should not be declared static

Section: 13.7.6  [temp.spec.partial]     Status: review     Submitter: Richard Smith     Date: 2024-07-24

(From submission #580.)

There appears to be no prohibition on applying the static storage class specifier to a variable template partial specialization. However, 6.6 [basic.link] clearly says that the name of the template has linkage (not its specializations). Implementations give specializations instantiated from a static partial specialization internal linkage even if the template has external linkage. This is undesirable.

Proposed resolution (approved by CWG 2024-08-16): [SUPERSEDED]

Add before 13.7.6.1 [temp.spec.partial.general] paragraph 10 as follows:

A partial specialization declaration for a variable template shall not have the storage-class-specifier static.

The usual access checking rules do not apply to non-dependent names used to specify template arguments of the simple-template-id of the partial specialization. ...

Additional notes (August, 2024)

If the primary template is declared static, the least breakage of existing code occurs if the partial specialization is required to also be declared static.

Possible resolution:

Add before 13.7.6.1 [temp.spec.partial.general] paragraph 10 as follows:

A partial specialization declaration for a variable template shall give its name the same linkage as the declaration of the primary template. A partial specialization declaration for a static data member template shall have the storage-class-specifier static.

The usual access checking rules do not apply to non-dependent names used to specify template arguments of the simple-template-id of the partial specialization. ...