Jump to conversation
Unresolved conversations (15)
@rainers rainers Jun 6, 2018
Would be nice if you could forward the dtor argument here, so it doesn't get lost when `delete` is called from C++ and the base class is also in C++ and handles it as expected.
src/dmd/clone.d
TurkeyMan rainers
@rainers rainers Jun 6, 2018
I don't think it can work so easily (AFAIU you are adding a parameter with a default value so it can still be called without arguments). This helps for explicit calls, but not for the dtor written to the TypeInfo. The latter needs a shim that adds the default value as an argument. Here's an example that calls the dtor this way: ``` import core.stdc.stdio; extern(C++) struct S { int x; ~this() { printf("~S %x\n", x); } } void main() { S[] arr = new S[3]; arr[1].x = 1; arr[2].x = 2; arr.length = 1; assumeSafeAppend(arr); // destroys arr[1] and arr[2] printf("done\n"); } ``` Output is: ``` ~S 2 ~S 1 done ~S 0 ``` Works for Win64, but not for Win32 in dmd 2.080. (Falsely assumes that C++ dtor does not have an argument, though).
src/dmd/dsymbolsem.d
TurkeyMan rainers
@jacob-carlborg jacob-carlborg Jun 6, 2018
When this now works for struct, the documentation should be updated [1]. [1] https://dlang.org/spec/traits.html#getLinkage
Outdated
test/compilable/test17419.d
@TurkeyMan TurkeyMan Jun 5, 2018
How can I also detect if `ad` is an `extern(C++) struct`??
Outdated
src/dmd/dsymbolsem.d
jacob-carlborg
@rainers rainers Jun 1, 2018
Would be good to test whether C++ and D agree on the position of the dtor in the vtable. Can you add some virtual functions, matching declarations in cppb.cpp and call the dtor from there?
Outdated
test/runnable/cppa.d
@rainers rainers Jun 1, 2018
This code can get executed again if semantic was deferred due to forward references (search for `addDeferredSemantic`). Instead of an assert, you could use the state `cppDtorVtblIndex` to avoid duplicate vtbl entries.
Outdated
src/dmd/dsymbolsem.d
@rainers rainers Jun 1, 2018
A final function can still override a base class implementation. It seems you cannot override non-virtual destructors anyway, so it should also check for the existence of a base class destructor?
Outdated
src/dmd/dsymbolsem.d
@dnadlinger dnadlinger May 26, 2018
This should mention C++, probably even in the member name.
Outdated
src/dmd/target.d
TurkeyMan
@TurkeyMan TurkeyMan May 24, 2018
Just FYI, someone might have more better idea here... `dsymbolSemantic` goes all wrong if I give it any hint that this function is virtual/override when it runs. It can't deal with reserved vtable slots like this here. The simplest solution seemed to fix up the relevant state (immediately below) after the function processes as if a normal non-virtual method. I didn't want to mess with the chaos in `dsymbolSemantic` to try and teach it about reserved vtable slots. And that would also add extra state to node structures too... so this hack(-ish) just below... looks okay?
Outdated
src/dmd/dsymbolsem.d
TurkeyMan
@TurkeyMan TurkeyMan May 24, 2018
What scope should the C++ global `operator delete` live in? Is there an 'outer scope', or a 'no scope'... some kind of global scope that lives outside the D namespace for special symbols that have no reference? Or is there a way to get to the `object` module from the compiler?
Outdated
src/dmd/dsymbolsem.d
TurkeyMan jacob-carlborg
kinke
@jacob-carlborg jacob-carlborg May 23, 2018
Curly braces on their own lines.
Outdated
test/runnable/cppa.d
jacob-carlborg TurkeyMan
@TurkeyMan TurkeyMan May 23, 2018
This line.... do I need it? When I step in there, it looks like it's always done it before.
src/dmd/clone.d
@jacob-carlborg jacob-carlborg May 23, 2018
Can this variable be `const`?
Outdated
src/dmd/dsymbolsem.d
jacob-carlborg TurkeyMan
@jacob-carlborg jacob-carlborg May 22, 2018
Why is `cppDtorVtblIndex` needed, why can't `cldec.dtor.vtblIndex` be used directly?
src/dmd/dsymbolsem.d
jacob-carlborg TurkeyMan
@JinShil JinShil May 22, 2018
I'm not sure about the approach in this PR, as I'm not all that familiar with the way vtables are built in D. However, we need to maintain both a C++ and D interface to DMD (unless I'm mistaken both LDC and GDC use the C++ interface). If you're adding a field to `ClassDelcaration`, I think you'll also need to update the same class in `aggregate.h` to keep the C++ interface compatible. cc @ibuclaw and @kinke.
Outdated
src/dmd/dclass.d
TurkeyMan
Resolved conversations (0)