GCC (all versions?) accepts mutable members of const-qualified/reference type in class templates, if the const-ness/reference-ness is introduced during instantiation: template <typename T> struct X { X(); mutable T x; }; X<const int> a; // no error X<int&> b; // no error
The mutable reference case was only fixed fairly recently for non-templates, as PR 33558, it looks like a later check is needed to handle templates.
Mine.
Fixed for 4.9.0 (r201925).