Bug 33558

Summary: 'mutable' incorrectly accepted on reference members
Product: gcc Reporter: Wolfgang Bangerth <bangerth>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: fang, gafunchal, gcc-bugs
Priority: P3 Keywords: accepts-invalid, patch
Version: 4.1.2   
Target Milestone: 4.6.0   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2008-12-31 17:59:36
Attachments: patch

Description Wolfgang Bangerth 2007-09-26 03:13:14 UTC
7.1.1/8 says that 'mutable' can't be applied to reference members:
  The mutable specifier can be applied only to names  of
  class  data  members  (_class.mem_)  and  cannot  be  applied to names
  declared const or static, and cannot be applied to reference  members.

Yet gcc accepts this code:
----------------
class X {
    mutable int &q;
};
----------------
This would seem to be in error.

W.
Comment 1 Andrew Pinski 2008-12-31 17:59:36 UTC
Confirmed.
Comment 2 Giovanni Funchal 2010-01-09 14:18:02 UTC
Created attachment 19523 [details]
patch
Comment 3 Giovanni Funchal 2010-01-09 14:18:54 UTC
http://gcc.gnu.org/ml/gcc-patches/2010-01/msg00420.html

-- Giovanni
Comment 4 Jonathan Wakely 2010-12-20 09:43:40 UTC
new patch http://gcc.gnu.org/ml/gcc-patches/2010-12/msg01469.html
Comment 5 Jonathan Wakely 2011-01-15 14:41:12 UTC
Author: redi
Date: Sat Jan 15 14:41:09 2011
New Revision: 168843

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=168843
Log:
2011-01-15  Giovanni Funchal  <gafunchal@gmail.com>
	    Jonathan Wakely  <jwakely.gcc@gmail.com>

	PR c++/33558
	* decl.c (grokdeclarator): Reject mutable reference members.


Added:
    trunk/gcc/testsuite/g++.dg/other/pr33558-2.C
    trunk/gcc/testsuite/g++.dg/other/pr33558.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 Jonathan Wakely 2011-01-15 14:42:39 UTC
Patch approved by Jason at http://gcc.gnu.org/ml/gcc-patches/2011-01/msg00918.html

Fixed for 4.6.0