This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/30331] a const member function can call a non_const member function without const_cast
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Dec 2006 08:08:50 -0000
- Subject: [Bug c++/30331] a const member function can call a non_const member function without const_cast
- References: <bug-30331-13838@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from pinskia at gcc dot gnu dot org 2006-12-30 08:08 -------
The following is ok:
static_cast<A>(*this).fun(); //ok
Because you are creating a rvalue to hold "*this" which is then bound to a
const lvalue.
The following is an error:
fun(); //err
Because func is not a non_const.
Or I am missing something because all the versions of GCC I tried give an
error.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |4.0.1 4.2.0 4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30331