[Bug c++/18975] Copying objects with mutable non-static data members

nathan at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Tue Dec 14 13:58:00 GMT 2004


------- Additional Comments From nathan at gcc dot gnu dot org  2004-12-14 13:57 -------
The code is invalid and the compiler correct.

The following line of reasoning is incorrect
- The implicitly defined copy constructor should use the copy constructor of
  PTR (12.8/8). Since the member ptr of XYZ is MUTABLE the (public) copy
  constructor PTR::PTR (PTR&) should be called after overload resolution:
  "PTR::PTR (PTR&)" is a better match than "PTR::PTR (const PTR&)".

[7.1.1/9] is unclear about *when* the mutable storage class specifier
'nullifies a const specifier applied to the containing class'.  However,
it has always been my understanding (and edg 3.4 appears to agree), that
the mutable applies at the point of assignment, not before, such as at
overload resolution.  After all, overload resolution has no knowledge that
an assignment will actually occur to the const value.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18975



More information about the Gcc-bugs mailing list