This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: c++/3760: g++ rejects legal code


The following reply was made to PR c++/3760; it has been noted by GNATS.

From: julian@OpenIT.DE (Julian v. Bock)
To: "Uwe F. Mayer" <mayer@tux.org>
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/3760: g++ rejects legal code
Date: 21 Jul 2001 21:22:42 +0200

 Hi
 
 >>>>> "Uwe" =3D=3D Uwe F Mayer <mayer@tux.org> writes:
 
     Uwe> c++ rejects to compile a member function changing a mutable
     Uwe> data member of a constant object instance. Direct changes of
     Uwe> the mutable member (if public) are fine.
     >> How-To-Repeat:
     Uwe> Compile the program bug8.cc included below, and you will get
     Uwe> the compile-time error message: $ g++ bug8.cc bug8.cc: In
     Uwe> function `int main()': bug8.cc:19: passing `const class_m' as
     Uwe> `this' argument of `void class_m::incr_i()' discards
     Uwe> qualifiers
 
 This is not a compiler bug.
 The compiler complains because you are trying to call a non-const
 member function of a const object. ("passing `const class_m' as `this'
 argument of `void class_m::incr_i()' discards qualifiers").
 
 Make class_m::incr_i a const member function and you are fine.
 
 Julian
 
 --=20
 OpenIT GmbH                        Tel +49 211 239 577-0
 Julian v. Bock                     Fax +49 211 239 577-10
 Jahnstr. 18                        julian@openit.de
 40215 D=FCsseldorf                   http://www.openit.de


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]