On Thu, 16 Jul 2026 at 11:58, Jakub Jelinek <[email protected]> wrote: > > Hi! > > The following marks these two templates with [[_Clang::no_specializations]] > because the P3019R14 paper which introduced them already added the > restrictions that they shouldn't be specialized by users. > > Tested on x86_64-linux, ok for trunk?
OK for trunk. > > I think I'll defer the rest to others (i.e. P2652R2 - std::allocator_traits, > P0912R5 - std::coroutine_handle and LWG4535 - <simd>). Yes, that's fine - we can do those. Thanks for making it possible by adding the attribute! > > 2026-07-16 Jakub Jelinek <[email protected]> > > PR c++/120635 > * include/bits/indirect.h (std::indirect, std::polymorphic): Add > _GLIBCXX_NO_SPECIALIZATIONS. > * testsuite/std/memory/indirect/specialization.cc: New test. > * testsuite/std/memory/polymorphic/specialization.cc: New test. > > --- libstdc++-v3/include/bits/indirect.h.jj 2026-04-24 14:30:10.752144148 > +0200 > +++ libstdc++-v3/include/bits/indirect.h 2026-07-16 11:24:31.563762066 > +0200 > @@ -68,7 +68,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > > // [indirect], class template indirect > template<typename _Tp, typename _Alloc> > - class indirect > + class _GLIBCXX_NO_SPECIALIZATIONS indirect > { > static_assert(is_object_v<_Tp>); > static_assert(!is_array_v<_Tp>); > @@ -467,7 +467,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > > // [polymorphic], class template polymorphic > template<typename _Tp, typename _Alloc> > - class polymorphic > + class _GLIBCXX_NO_SPECIALIZATIONS polymorphic > { > static_assert(is_object_v<_Tp>); > static_assert(!is_array_v<_Tp>); > --- libstdc++-v3/testsuite/std/memory/indirect/specialization.cc.jj > 2026-07-16 11:57:09.678788363 +0200 > +++ libstdc++-v3/testsuite/std/memory/indirect/specialization.cc > 2026-07-16 12:41:25.312399734 +0200 > @@ -0,0 +1,13 @@ > +// { dg-do compile { target c++26 } } > + > +#include <memory> > + > +struct A {}; > +template<typename T> > +struct B {}; > + > +template<> > +class std::indirect<A, std::pmr::polymorphic_allocator <A>> {}; > // { dg-error "cannot be specialized" } > + > +template<typename T> > +class std::indirect<B<T>, std::pmr::polymorphic_allocator <B<T>>> {}; // { > dg-error "cannot be specialized" } > --- libstdc++-v3/testsuite/std/memory/polymorphic/specialization.cc.jj > 2026-07-16 11:57:09.679876265 +0200 > +++ libstdc++-v3/testsuite/std/memory/polymorphic/specialization.cc > 2026-07-16 12:41:35.006279624 +0200 > @@ -0,0 +1,13 @@ > +// { dg-do compile { target c++26 } } > + > +#include <memory> > + > +struct A {}; > +template<typename T> > +struct B {}; > + > +template<> > +class std::polymorphic<A, std::pmr::polymorphic_allocator <A>> {}; > // { dg-error "cannot be specialized" } > + > +template<typename T> > +class std::polymorphic<B<T>, std::pmr::polymorphic_allocator <B<T>>> {}; > // { dg-error "cannot be specialized" } > > Jakub >
