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

Ethan gooberman at gmail.com
Sun Jul 28 15:33:45 UTC 2019


On Saturday, 27 July 2019 at 19:58:05 UTC, Ethan wrote:
> tl;dr is "How do I make the compiler behave the way I want it 
> to?"

Write the code myself of course.

I've got a solution working locally.

And looking at the implementation that was already there... I'm 
not going to submit a pull request just yet. The code only checks 
for the existence of virtuals, it doesn't care if one of those 
virtuals is a destructor or not. This isn't good enough as I see 
it. So I'm going to think about how best to tackle that.

But hey, my code compiles and executes perfectly now that I have 
a solution.

There is *one* thing I'm going to get a pull request ready for 
however Compile this code using a Windows DMD:

----------

extern( C++ ) class SomeClass
{
     @property someString() const { return "Wahoo"; }
}

----------

Compiler output:
Internal Compiler Error: type `string` can not be mapped to C++

----------

This is a Windows only problem. Linux builds have no issue with 
slices of any kind. So that's one problem that I'm going to 
analyse and fix in another pull request. Probably requires the 
codegen to define a virtual Slice struct knowing how Windows 
works.

But what I'm interested in is that ICE.

So here's the thing with every ICE in cppmanglewin.d. Every 
single one of them is as the result of a user error. As near as I 
can tell, an ICE is raised because it wants compilation to just 
plain stop and go no further. It's not an unexpected state, it's 
a state it knows the user can input but compilation past that 
point is plain wrong as far as it's concerned.

And yet none of these ICE give the file and line number in the 
log.

"So just go through your extern( C++ ) objects and look for-" 
Yeah, nah, how about I get a file and line in the output that I 
can double click on in my IDE (it's Windows so of course I mean 
Visual Studio) and go straight to the problem. Massive time saver.

That change I've got there is quite self contained, so a pull 
request will be incoming for that.


More information about the Digitalmars-d mailing list