https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113303
Bug ID: 113303
Summary: One can assign to const reference in a template
partial specialization
Product: gcc
Version: 13.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: fchelnokov at gmail dot com
Target Milestone: ---
This program
template <auto &>
struct A;
template <const auto & a>
struct A<a>{
A() { a = 1; }
};
int x = 0;
A<x> s;
is erroneously accepted by GCC despite the assignment to const reference.
Clang complains that "class template partial specialization is not more
specialized than the primary template".
And MSVC allows the specialization, but "you cannot assign to a variable that
is const"
Online demo: https://godbolt.org/z/1aPK8K311