🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #1198

Re: Compiler should generate virtual destructors

#1198
From: John MAX Skaller
Date: Sun, 03 Jan 1993 03:10
39 lines
2041 bytes
In article <9300301.307@mulga.cs.mu.OZ.AU> fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
>maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
>
>>I would like to propose that if a class has virtual functions,
>>then any destructor generated by the compiler will be virtual
>>by default.
>>
>>Advantages: much safer, ensures correct deletion of objects
>>by default.  Removes a source of bugs. Removes the reminder
>>that its wise to do this from the FAQ.
>>
>>Disadvantage: might slow down destruction a little. Can be
>>fixed by the programmer explicitly declaring a non-virtual
>>destructor.
>
>I think that this situation should cause a compiler warning, rather
>than adding another arbitrary rule in the language for programmers to
>remember. 

	What arbitrary rule? Do you mean the rule that says
automatically generated destructors are *non-virtual* :-) ??

	The point here is that the forgetful programmer is protected.

>[Off the topic, another situation that should have a required warning
>is the (void *) to (T *) conversion. 


	void *x;
	T* t;
	t=x; // error here, no mere warning
	t=(T*)x; // warning inserted by programmer in the form of (T*)
	t=reinterpret_cast<T*>x; // grepable warning 

-- 
;----------------------------------------------------------------------
        JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
	Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
Technical Details
Message-ID: <1993Jan3.031032.12747@ucc.su.OZ.AU>
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
References: <1992Dec31.050150.28929@ucc.su.OZ.AU> <9300301.307@mulga.cs.mu.OZ.AU>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
Subject: Re: Compiler should generate virtual destructors
Message-ID: <1993Jan3.031032.12747@ucc.su.OZ.AU>
Sender: news@ucc.su.OZ.AU
Nntp-Posting-Host: extro.ucc.su.oz.au
Organization: MAXTAL P/L C/- University Computing Centre, Sydney
References: <1992Dec31.050150.28929@ucc.su.OZ.AU> <9300301.307@mulga.cs.mu.OZ.AU>
Date: Sun, 3 Jan 1993 03:10:32 GMT
Lines: 39