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

            Bug ID: 120635
           Summary: Support something like [[clang::no_specializations]]
                    attribute
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

C++ made it ill-formed to specialize std::initializer_list:
https://cplusplus.github.io/LWG/issue2129

It's likely that a similar change will be made for other class templates in the
standard library (e.g. maybe C++26's std::type_order).

Rather than special-casing each class template in the compiler, it would make
sense to have an attribute which the library can put on class template.

Clang 20 already has this:
https://releases.llvm.org/20.1.0/tools/clang/docs/AttributeReference.html#no-specializations


The docs say "explicitly specialized" but the attribute also prevents partial
specializations:

<source>:4:29: error: 'X' cannot be specialized [-Winvalid-specialization]
    4 | template<typename U> struct X<int, U> { };
      |                             ^
<source>:2:10: note: marked 'no_specializations' here
    2 | struct [[clang::no_specializations]] X { };
      |          ^

Reply via email to