Skip to content

do not add "const" to virtual override functions in C++ headers#5673

Merged
WalterBright merged 1 commit intodlang:masterfrom
rainers:override_const
Apr 16, 2016
Merged

do not add "const" to virtual override functions in C++ headers#5673
WalterBright merged 1 commit intodlang:masterfrom
rainers:override_const

Conversation

@rainers
Copy link
Member

@rainers rainers commented Apr 16, 2016

In C++, adding const to a virtual member function does not override the member function of the base class. The dmd headers do not repeat "virtual", so a new non-virtual member function is added.

Removing "const" from the declarations might cause inconsistent mangling, but calling these functions from C++ (as LDC does for a few, see ldc-developers/ldc#1421) is probably expecting the virtual call anyway (which does not need any mangled symbols).

With enough type information the optimizer might still attempt to call the virtual function directly with wrong mangling, but with this PR the failure is not silent anymore.

@WalterBright
Copy link
Member

Auto-merge toggled on

@WalterBright WalterBright merged commit 319288f into dlang:master Apr 16, 2016
rainers added a commit to rainers/ldc that referenced this pull request Apr 17, 2016
manual port of dmd commit c838a96a47b783c5a7e08abbd5761f14e19b6233
see dlang/dmd#5673
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants