🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Explicit call of pure virtual function sneaks past

#1068
From: jimc
Date: Thu, 15 Oct 1992 08:28
25 lines
1193 bytes
// g++ v2.2.2 for Sun-Sparc-SunOS v4.1.1
// Explicit call of pure virtual function compiles (shouldn't?) and
// code bombs (should use virtual table?)

#include <iostream.h>

struct base {
    virtual void mbrfunc() = 0;
};

struct derived : public base {
    void mbrfunc() 
	{ cout << "derived::mbrfunc\n"; }
};

int main() {
    derived d;
    d.mbrfunc();		// prints derived::mbrfunc, correctly
    d.base::mbrfunc();		// prints ABORT (should not compile)
}

James F. Carter        Voice 310 825 2897	FAX 310 206 6673
UCLA-Mathnet;  6221 MSA; 405 Hilgard Ave.; Los Angeles, CA, USA  90024-1555
Internet: jimc@math.ucla.edu            BITNET: jimc%math.ucla.edu@INTERBIT
UUCP:...!{ucsd,ames,ncar,gatech,purdue,rutgers,decvax,uunet}!math.ucla.edu!jimc
Technical Details
Message-ID: <9210152228.AA12362@julia.math.ucla.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!math.ucla.edu!jimc

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!math.ucla.edu!jimc
From: jimc@math.ucla.edu
Subject: Explicit call of pure virtual function sneaks past
Message-ID: <9210152228.AA12362@julia.math.ucla.edu>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Thu, 15 Oct 1992 08:28:15 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 26