www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20235] New: C++ ABI doesn't destruct struct arguments in the

https://issues.dlang.org/show_bug.cgi?id=20235

          Issue ID: 20235
           Summary: C++ ABI doesn't destruct struct arguments in the
                    callee
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: sahmi.soulaimane gmail.com

C++ doesn't call the destructor or value parameters in the callee.

C++:
```
struct S { ~S(){} };

void fuc(S)
{
}
```
https://cpp.godbolt.org/z/NJt_5s
No call to the destructor.

D:
```
extern(C++):

struct S { ~this(){} }

void fuc(S)
{
}
```
https://d.godbolt.org/z/5yzcFS
It calls the destructor.

This causes some double free bugs.

--
Sep 21 2019