https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108169
Bug ID: 108169 Summary: class type template parameters are non-const in GCC (differs from other compilers) Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: danakj at orodu dot net Target Milestone: --- Reproduces on GCC 10, 11, 12 and Trunk. An auto template parameter's type is const in Clang and MSVC, but is considered non-const in GCC. This does not occur with primitive types, but it does with class types. This is a C++20 bug, as C++20 introduced class type template parameters. With -std=c++17, gcc states as such: ``` <source>:15:26: error: non-type template parameters of class type only available with '-std=c++20' or '-std=gnu++20' ``` Source code: ``` #include <type_traits> template <auto V> struct S { static constexpr bool is_const = std::is_const_v<decltype(V)>; }; struct W { constexpr W(int i) : i(i) {} int i; }; int main() { static_assert(!S<1>::is_const); // pass static_assert(!S<W(2)>::is_const); // fail } ``` Godbolt: https://godbolt.org/z/WEbPcjzcK