Thread overview
[Issue 12636] extern(C++) class that implements D interface segfaults
Jul 25, 2014
yebblies
Jul 28, 2014
yebblies
Sep 09, 2014
yebblies
April 24, 2014
https://issues.dlang.org/show_bug.cgi?id=12636

Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|Mac OS X                    |All

--- Comment #1 from Steven Schveighoffer <schveiguy@yahoo.com> ---
Tested on Windows and MacOSX 64 bit.

--
July 25, 2014
https://issues.dlang.org/show_bug.cgi?id=12636

yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies@gmail.com

--- Comment #2 from yebblies <yebblies@gmail.com> ---
I'm not sure this _can_ work.  Converting from a class reference to an interface reference requires adjusting the this pointer so it picks up the correct vtable (IIRC) and you can't do this without classinfo (again IIRC).

There is no such thing as COM classes, on COM interfaces, and COM classes would have the same problem.  A D class implementing an extern(C++) interface should work.

If so, this should probably be rejected at compile time.

--
July 28, 2014
https://issues.dlang.org/show_bug.cgi?id=12636

--- Comment #3 from Steven Schveighoffer <schveiguy@yahoo.com> ---
A class that implements a COM interface, has default linkage other than
extern(D). I thought it was similar to how extern(C++) works.

I don't know what the internal difference is between extern(C++) classes and D classes, but I can understand if we cannot implement both ABIs in the same class. I have to trust you on that one :) TBH, I'm not really interested in making this work, it was a test I ran to see if it did after telling someone on d.learn that you can't create C++ classes in D, and you corrected me.

Feel free to overtake this bug as an "Accepts invalid".

--
July 28, 2014
https://issues.dlang.org/show_bug.cgi?id=12636

--- Comment #4 from yebblies <yebblies@gmail.com> ---
(In reply to Steven Schveighoffer from comment #3)
> A class that implements a COM interface, has default linkage other than
> extern(D). I thought it was similar to how extern(C++) works.

extern(C++) interfaces work the same as COM interfaces except for linkage. Classes on the other hand...

> 
> I don't know what the internal difference is between extern(C++) classes and D classes, but I can understand if we cannot implement both ABIs in the same class. I have to trust you on that one :)

Yeah, either the first vtable entry is the classinfo pointer or not, there isn't much middle ground there.

> TBH, I'm not really interested in
> making this work, it was a test I ran to see if it did after telling someone
> on d.learn that you can't create C++ classes in D, and you corrected me.
> 
> Feel free to overtake this bug as an "Accepts invalid".

At the very least it's a diagnostic issue.  Should be easy enough to detect.

--
September 09, 2014
https://issues.dlang.org/show_bug.cgi?id=12636

--- Comment #5 from yebblies <yebblies@gmail.com> ---
Pull to make it error:

https://github.com/D-Programming-Language/dmd/pull/3967

--
September 10, 2014
https://issues.dlang.org/show_bug.cgi?id=12636

--- Comment #6 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/3ef3d64cd0b37e44f09a4652c086beb98e990e14 Fix Issue 12636 - extern(C++) class that implements D interface segfaults

https://github.com/D-Programming-Language/dmd/commit/dfad66748eac76fb55393505803910d650dbdf1b Merge pull request #3967 from yebblies/issue12636

Issue 12636 - extern(C++) class that implements D interface segfaults

--
September 10, 2014
https://issues.dlang.org/show_bug.cgi?id=12636

github-bugzilla@puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--
February 18, 2015
https://issues.dlang.org/show_bug.cgi?id=12636

--- Comment #7 from github-bugzilla@puremagic.com ---
Commits pushed to 2.067 at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/3ef3d64cd0b37e44f09a4652c086beb98e990e14 Fix Issue 12636 - extern(C++) class that implements D interface segfaults

https://github.com/D-Programming-Language/dmd/commit/dfad66748eac76fb55393505803910d650dbdf1b Merge pull request #3967 from yebblies/issue12636

--