public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/30331]  New: a const member function can call a non_const member function without const_cast
@ 2006-12-30  7:58 hongleij at 126 dot com
  2006-12-30  8:09 ` [Bug c++/30331] " pinskia at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: hongleij at 126 dot com @ 2006-12-30  7:58 UTC (permalink / raw)
  To: gcc-bugs

//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()
  {
  }
  unsigned int aa;
};

int main()
{
    const A a(56);
    a.const_fun();
}

//  g++ const_test.cpp
//  ./a.out
//we should forbid call non_const member function  in a const member function
without an explicit const_cast ,isn't it?


-- 
           Summary: a const member function can call a non_const member
                    function without const_cast
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hongleij at 126 dot com
  GCC host triplet: all


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2006-12-31  2:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-30  7:58 [Bug c++/30331] New: a const member function can call a non_const member function without const_cast 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
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 ` gdr at gcc dot gnu dot org
2006-12-30 17:53 ` pinskia at gcc dot gnu dot org
2006-12-31  2:24 ` hongleij at 126 dot com

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).