home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / gnu / g / bug / 2314 < prev    next >
Encoding:
Text File  |  1993-01-23  |  772 b   |  35 lines

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cse.ucsc.EDU!dlong
  2. From: dlong@cse.ucsc.EDU (Dean R. E. Long)
  3. Newsgroups: gnu.g++.bug
  4. Subject: g++ 2.3.3 const non-warning
  5. Date: 22 Jan 1993 21:45:33 -0500
  6. Organization: University of California, Santa Cruz (CE/CIS Boards)
  7. Lines: 22
  8. Sender: daemon@cis.ohio-state.edu
  9. Approved: bug-g++@prep.ai.mit.edu
  10. Distribution: gnu
  11. Message-ID: <1jpmd4INN56o@darkstar.UCSC.EDU>
  12.  
  13. I would expect g++ to give me a warning for calling a non-const
  14. member function with a const object in the following, but it does not:
  15.  
  16. class B {
  17.     int x;
  18. public:
  19.     void foo(void) { x = 1; }
  20. };
  21.  
  22. class A {
  23.     B *p;
  24. public:
  25.     A() { p = 0; }
  26.     const B & ro() { return *p; }
  27. };
  28.  
  29. main()
  30. {
  31.     A a;
  32.     a.ro().foo();    // warn me, please!
  33. }
  34.  
  35.