D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21271 - C++ header generation ignores extern(D) class methods affecting vtable layout
Summary: C++ header generation ignores extern(D) class methods affecting vtable layout
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2020-09-23 11:52 UTC by kinke
Modified: 2020-10-18 15:54 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description kinke 2020-09-23 11:52:26 UTC
Leading to a corrupt C++ vtable, e.g.:

extern(C++) class C
{
    extern(D) void virtualFoo1() {}
    void virtualFoo2() {}
}

dmd -HC ... =>

class C
{
public:
    // ignoring extern () block because of linkage
    virtual void virtualFoo2();
};

Overridden virtual functions can probably be still ignored, but new virtual functions need a dummy declaration on the C++ side.
Comment 1 Dlang Bot 2020-10-18 15:11:12 UTC
@MoonlightSentinel updated dlang/dmd pull request #11872 "dtoh: Emit placeholders for skipped virtual functions" fixing this issue:

- Fix 21271: Emit placeholders for skipped virtual functions (dtoh)
  
  This ensures proper vtable layout for classes which
  have extern(D) functions

https://github.com/dlang/dmd/pull/11872
Comment 2 Dlang Bot 2020-10-18 15:54:43 UTC
dlang/dmd pull request #11872 "dtoh: Emit placeholders for skipped virtual functions" was merged into master:

- 2e9015871a058a0b16ace6bc9e285d3de4027b46 by MoonlightSentinel:
  Fix 21271: Emit placeholders for skipped virtual functions (dtoh)
  
  This ensures proper vtable layout for classes which
  have extern(D) functions

https://github.com/dlang/dmd/pull/11872