Bug 56380

Summary: Const/reference mutable members are not always rejected in class templates
Product: gcc Reporter: Paul Smith <pl.smith.mail>
Component: c++Assignee: Paolo Carlini <paolo.carlini>
Status: RESOLVED FIXED    
Severity: normal CC: daniel.kruegler
Priority: P3 Keywords: accepts-invalid
Version: unknown   
Target Milestone: 4.9.0   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2013-02-18 00:00:00

Description Paul Smith 2013-02-18 16:59:50 UTC
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
Comment 1 Jonathan Wakely 2013-02-18 17:50:16 UTC
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.
Comment 2 Paolo Carlini 2013-08-22 10:26:50 UTC
Mine.
Comment 3 Paolo Carlini 2013-08-22 16:32:23 UTC
Fixed for 4.9.0 (r201925).