Title
Attributes for an explicit specialization
Status
open
Section
13.9.4 [temp.expl.spec]
Submitter
Aaron Ballman

Created on 2022-06-23.00:00:00 last changed 1 month ago

Messages

Date: 2022-06-24.08:14:12

Suggested resolution:

Change in 13.9.4 [temp.expl.spec] paragraph 13 as follows:

Any attributes applying to any part of the declaration of an explicit specialization of a function or variable template, as well as Whether whether such an explicit specialization of a function or variable template is inline, constexpr, or an immediate function, is determined by the explicit specialization and is independent of those properties of the template. [ Note: Attributes that would affect the association of the declaration of an explicit specialization with the declaration of the primary template need to match. -- end note ]
Date: 2022-06-23.00:00:00

It is unclear whether an explicit template specialization "inherits" the attributes written on the primary template, or whether the specialization has to repeat the attributes. For example:

  template <typename Ty>
  [[noreturn]] void func(Ty);

  template <>
  void func<int>(int) {
    // Warning about returning from a noreturn function or not?
  }

A similar question arises for attributes written on the parameters of the primary function template. For example:

  template <typename Ty>
  void func([[maybe_unused]] int i);

  template <>
  void func<int>(int i) {
   // i is not used, should it be warned on or not?
  }

There is implementation divergence for the example.

History
Date User Action Args
2022-06-24 08:14:12adminsetmessages: + msg6867
2022-06-23 00:00:00admincreate