Title
Variable template partial specializations should not be declared static
Status
review
Section
13.7.6 [temp.spec.partial]
Submitter
Richard Smith

Created on 2024-04-24.00:00:00 last changed 1 month ago

Messages

Date: 2025-11-06.23:04:52

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. ...

Date: 2024-08-15.00:00:00

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.

Date: 2024-08-29.21:20:31

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. ...

Date: 2024-04-24.00:00:00

(From submission #580.)

There appears to be no prohibition on applying the static storage class specifier to a variable template partial specialization. However, 6.7 [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.

History
Date User Action Args
2025-11-06 23:04:52adminsetmessages: + msg8304
2024-08-29 21:20:31adminsetmessages: + msg7810
2024-08-29 21:20:31adminsetstatus: tentatively ready -> review
2024-08-16 19:45:15adminsetstatus: open -> tentatively ready
2024-07-29 22:31:57adminsetmessages: + msg7776
2024-04-24 00:00:00admincreate