🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #1402

g++ 2.3.3 const non-warning

#1402
From: Dean R. E. Long
Date: Sat, 23 Jan 1993 02:45
21 lines
804 bytes
I would expect g++ to give me a warning for calling a non-const
member function with a const object in the following, but it does not:

class B {
    int x;
public:
    void foo(void) { x = 1; }
};

class A {
    B *p;
public:
    A() { p = 0; }
    const B & ro() { return *p; }
};

main()
{
    A a;
    a.ro().foo();	// warn me, please!
}
Technical Details
Message-ID: <1jpmd4INN56o@darkstar.UCSC.EDU>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cse.ucsc.EDU!dlong

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cse.ucsc.EDU!dlong
From: dlong@cse.ucsc.EDU (Dean R. E. Long)
Newsgroups: gnu.g++.bug
Subject: g++ 2.3.3 const non-warning
Date: 22 Jan 1993 21:45:33 -0500
Organization: University of California, Santa Cruz (CE/CIS Boards)
Lines: 22
Sender: daemon@cis.ohio-state.edu
Approved: bug-g++@prep.ai.mit.edu
Distribution: gnu
Message-ID: <1jpmd4INN56o@darkstar.UCSC.EDU>