public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "hongleij at 126 dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/30331] a const member function can call a non_const member function without const_cast Date: Sat, 30 Dec 2006 13:46:00 -0000 [thread overview] Message-ID: <20061230134622.16923.qmail@sourceware.org> (raw) In-Reply-To: <bug-30331-13838@http.gcc.gnu.org/bugzilla/> ------- Comment #3 from hongleij at 126 dot com 2006-12-30 13:46 ------- the question is : if a const member function can call a non_const member function without const_cast, if fun() changed the member in A,like this: //const_test.cpp struct A { A(unsigned int n) { aa=n; } void const_fun() const { static_cast<A>(*this).fun(); //ok // fun(); //err } void fun() { aa=78; } unsigned int aa; }; int main() { const A a(56); a.const_fun(); } the sematic of bitwise constness is not confirmed. this program is inspired from the book <Effective C++>(third edition) Item3: use const whenever possible -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30331
next prev parent reply other threads:[~2006-12-30 13:46 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2006-12-30 7:58 [Bug c++/30331] New: " hongleij at 126 dot com 2006-12-30 8:09 ` [Bug c++/30331] " pinskia at gcc dot gnu dot org 2006-12-30 11:21 ` gdr at integrable-solutions dot net 2006-12-30 13:46 ` hongleij at 126 dot com [this message] 2006-12-30 13:49 ` hongleij at 126 dot com 2006-12-30 17:51 ` gdr at integrable-solutions dot net 2006-12-30 17:53 ` pinskia at gcc dot gnu dot org 2006-12-30 17:53 ` gdr at gcc dot gnu dot org 2006-12-31 2:24 ` hongleij at 126 dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20061230134622.16923.qmail@sourceware.org \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).