Bug 33558 - 'mutable' incorrectly accepted on reference members
Summary: 'mutable' incorrectly accepted on reference members
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.2
: P3 normal
Target Milestone: 4.6.0
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid, patch
Depends on:
Blocks:
 
Reported: 2007-09-26 03:13 UTC by Wolfgang Bangerth
Modified: 2011-01-15 14:42 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-12-31 17:59:36


Attachments
patch (412 bytes, patch)
2010-01-09 14:18 UTC, Giovanni Funchal
Details | Diff

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