forcing "@nogc" on class destructors

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Thu Jan 22 08:53:10 PST 2015


On 1/22/15 10:59 AM, "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= 
<ola.fosheim.grostad+dlang at gmail.com>" wrote:
> On Thursday, 22 January 2015 at 11:58:13 UTC, Steven Schveighoffer wrote:
>> A race condition can LEAD to this being triggered, but the abort
>> itself is not a race condition. And forcing a default of @nogc will
>> not fix this.
>
> Why not? If you have a race condition that leads a memory leak when
> using explicit deallocation, then that leak will lead to destructor
> being run by the collector. Which will fail if the destructor
> gc-allocates. GC is meant to make allocation safer, not less safe.

Disallowing compilation of the dtor does not fix the race condition. We 
are no closer to race-free code here.

What you are basically saying is, race conditions are OK, as long as 
they don't allocate memory in dtors.

-Steve


More information about the Digitalmars-d mailing list