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

elpenguin...@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |elpenguin...@gmail.com

--- Comment #1 from elpenguin...@gmail.com ---
I think this is the wrong way to approach the issue. It is perfectly valid for
a destructor to allocate using the GC, as long as the struct itself is not
allocated using the GC.

Example code:
```
import std.stdio;
struct Predictable
{
    string id;    
    this(string _id)
    {
        writeln("Constructor ", _id);
        id = _id;
    }
    ~this()
    {
        writeln("Destructor " ~ id);
    }
}

void main()
{
    Predictable result = Predictable("1");
}
```
outputs two lines, 'Constructor 1' and 'Destructor 1' without issue.

I'd say it's better to simply forbid anything with a non-@noGC destructor from
being used with new or array reallocation instead.

--

Reply via email to