D-Programming-Language/dmd — pull request #4072 by mleise (2014-10-17 21:10:54+00:00)
Title: Issue 12004 and issue 13174: Disallow shared destructors and always call the unshared one.

When using shared structs, the compiler asks for a shared ~this() which should not exist in the language at all. The destructor for these value types must be run when all threads that could reference it have finished and only the owner thread is left. It is a logical error to have a destructor run in a "shared" environment.

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

It's only 6 lines of changes, but the indentation level change in src/template.c makes it look wild. What it says is basically:
```D
if (fd->isDtorDeclaration() && tthis_fd->isShared())
{
tthis_fd = tthis_fd->unSharedOf();
}
```
Since I hit the bug once again and there was now someone else struggling with it and `shared` needs some love, I decided to peek into the dmd code and make some quick adjustments. I ran the test suite and unittests, but there is one thing I'm not sure about: Even when `this` is `shared`, it will call the unmatching dtor.