Bug 56380 - Const/reference mutable members are not always rejected in class templates
Summary: Const/reference mutable members are not always rejected in class templates
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: 4.9.0
Assignee: Paolo Carlini
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2013-02-18 16:59 UTC by Paul Smith
Modified: 2013-08-22 16:32 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-02-18 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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).