Skip to content

Change mangling of extern(C++) ctor.#1357

Closed
redstar wants to merge 1 commit intoldc-developers:ltsmasterfrom
redstar:cppmangle
Closed

Change mangling of extern(C++) ctor.#1357
redstar wants to merge 1 commit intoldc-developers:ltsmasterfrom
redstar:cppmangle

Conversation

@redstar
Copy link
Member

@redstar redstar commented Mar 16, 2016

This is a part of issue #1312.

@redstar
Copy link
Member Author

redstar commented Mar 16, 2016

@kinke Does this help for ctor mangling?

@kinke
Copy link
Member

kinke commented Mar 18, 2016

Thx Kai, I'll check it over the weekend.
So this should allow using C++ ctors from D by just declaring them in D. But this doesn't fix the actual mangling bug in #1312.

@yebblies
Copy link

Without also matching the ABI, matching mangling is a little dangerous.

@kinke
Copy link
Member

kinke commented Mar 20, 2016

That's what I thought too. You mean the different destruction rules, right? Does the front-end support argument destruction by the caller for extern(C++) functions?

@yebblies
Copy link

I'm not sure. The issue I've had trouble with is that D will blit init[] over before calling the constructor, while C++ won't. We should (hopefully) be matching argument destruction correctly for normal C++ calls, or is it different for ctors?

@kinke
Copy link
Member

kinke commented Mar 20, 2016

D will blit init[] over before calling the constructor, while C++ won't.

I'd think that a C++ ctor cannot make any assumptions about the initial payload, so I'd consider blitting to be useless (and affecting runtime a bit when calling it from D) but not troublesome.

We should (hopefully) be matching argument destruction correctly for normal C++ calls

That's what I wanted to hear - very good.

@yebblies
Copy link

I'd think that a C++ ctor cannot make any assumptions about the initial payload, so I'd consider blitting to be useless (and affecting runtime a bit when calling it from D) but not troublesome.

When calling a ctor written in C++ from D, yes. But when going the other way the ctor may not init all fields.

@kinke
Copy link
Member

kinke commented Mar 20, 2016

But when going the other way the ctor may not init all fields.

True. That could be compensated for when generating an extern(C++) ctor implemented in D by having the front-end inject the blitting at the beginning of the ctor (instead of blitting before calling it from D). We could also simply define the semantics for extern(C++) ctors implemented in D as fully C++ compatible, i.e., no implicit pre-init - but that would break ddmd I guess.

@redstar
Copy link
Member Author

redstar commented Jun 28, 2016

Closing in favor of dlang/dmd#5884.

@redstar redstar closed this Jun 28, 2016
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.

3 participants