Error: C++ base class needs at least one virtual function

Ethan gooberman at gmail.com
Sun Jul 28 11:13:27 UTC 2019


On Sunday, 28 July 2019 at 09:27:56 UTC, Johan Engelen wrote:
> Can I rephrase your point as this?
> Normal D classes do not require their parent to have at least 
> one virtual function, but extern(C++) classes do. Please remove 
> this limitation from extern(C++) classes.
>
> -Johan

That's not accurate.

Normal D classes without a defined parent have Object as a 
parent, which defines 4 virtuals at last count. The "no virtuals" 
template in my code that static asserts when a virtual is 
detected specifically ignores Object and its virtuals (and also 
static asserts if a user overrides those virtuals).

If I said I wanted the limitation removed coming in, the obvious 
counterpoint is "But memory safety is thrown out the window 
without virtual destructors so we absolutely should enforce 
this." To which I'd have nothing except that I don't need it in 
my use case.

I'm not asking to remove the limitation. I'm asking for an option 
to disable the error because I have a valid use case for it and I 
know what I'm doing.


More information about the Digitalmars-d mailing list