Skip to content

fix #23262 - [REG v2.113.0-beta.1] ICE when trying to cast a class instance to a C++ interface#23263

Open
rainers wants to merge 2 commits into
dlang:stablefrom
rainers:issue_23262
Open

fix #23262 - [REG v2.113.0-beta.1] ICE when trying to cast a class instance to a C++ interface#23263
rainers wants to merge 2 commits into
dlang:stablefrom
rainers:issue_23262

Conversation

@rainers

@rainers rainers commented Jun 14, 2026

Copy link
Copy Markdown
Member

no need to exclude C++ classes/interfaces from runtime cast target

…ss instance to a C++ interface

no need to exclude C++ classes/interfaces from runtime cast target
@dlang-bot

Copy link
Copy Markdown

Thanks for your pull request, @rainers!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

⚠️⚠️⚠️ Warnings ⚠️⚠️⚠️

  • In preparation for migrating from Bugzilla to GitHub Issues, the issue reference syntax has changed. Please add the word "Bugzilla" to issue references. For example, Fix Bugzilla Issue 12345 or Fix Bugzilla 12345.(Reminder: the edit needs to be done in the Git commit message, not the GitHub pull request.)

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "stable + dmd#23263"

Comment thread compiler/test/runnable/casting.d
Comment thread compiler/src/dmd/expressionsem.d Outdated
Comment thread compiler/test/runnable/casting.d Outdated
Comment on lines +229 to +230
auto cpp = cast(iface23262) obj;
assert(cpp);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails going the other way though, as C++ interfaces don't contain an Interface record.

    auto dpl = cast(class23262)(cpp);
    assert(dpl);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, casting from C++ to D classes is not supported. I can add that test, too, if it makes the direction clearer.

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.

4 participants