-
-
Notifications
You must be signed in to change notification settings - Fork 667
fix Issue 14246 - RAII - proper destruction of partially constructed … #6816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
1a23439 to
d55c3ed
Compare
|
@WalterBright doesn't this change language semantics quite a bit ? |
|
Where are the tests? And do we still have constructs that can't be used inside of try/catch blocks that will trip up here? |
I forgot to commit it. Done.
I don't think so. It's the whole point of |
It's expected behavior, so I consider it fixing a bug. |
|
Spec pull: dlang/dlang.org#1658. Question: with the current code, is a dtor call issued for members that are not initialized by means of a ctor (i.e. those implicitly initialized with .init)? |
With this PR, yes. Since a .init initialized object is a valid object, running the destructor on it must be benign. This is, of course, inefficient as it is not necessary to run the destructor on them. However, it is also inefficient to otherwise generate all the different exception handling contexts, one for each constructor run. I decided to do it this way based on the notion that throwing exceptions during construction is a rare event, and not the path that should be optimized. Just to be clear, destructors are only run for fields that are of types with destructors. |
|
@WalterBright ok, updated dlang/dlang.org#1658 |
|
@WalterBright please review dlang/dlang.org#1658 |
|
Removed auto-merge to de-prioritize the build until it passes tests. |
|
This pull request broke Reduced test case: struct S
{
~this() {}
}
class C
{
S s;
this() nothrow {}
}Compiler now complains: |
|
Bug reports (including regressions) should be reported to Bugzilla. I did this one: https://issues.dlang.org/show_bug.cgi?id=17493 |
Just checking whether there are more hidden regressions on Jenkins or whether this is the last one: |
|
So D-YAML and EMSI containers are affected as well from this PR. Jenkins does report the error for EMSI containers, it just doesn't trigger an error: CC @MartinNowak edit: it seems that EMSI had linkage errors before and thus was disabled ( |
|
Reduction for D-YAML class Scanner
{
import std.container.array : Array;
Array!int indents_;
this() @safe {}
}Yields: edit, without Phobos: struct Array
{
int[] _payload;
~this()
{
import core.stdc.stdlib : free;
free(_payload.ptr);
}
}
class Scanner
{
Array arr;
this() @safe {}
} |
|
Reducing EMSI wasn't that successful, but maybe still helpful? struct TreeMap(K)
{
this() @disable;
import ttree;
TTree!int tree;
}
unittest
{
TreeMap!int;
TreeMap!string;
}
struct TTree(T)
{
this() @disable;
~}Since this PR: With 2.074.0: |
The extra |
It looks like there is an error in your reduction test script. |
Ah, yeah - I gave it a couple of new tries and ended with this nice reduction for EMSI containers: struct TreeMap
{
this() @disable;
this(TTree tree) { this.tree = tree; }
TTree tree;
}
struct TTree
{
this() @disable;
this(int foo) {}
~this() {}
}
void main()
{
auto k = TreeMap(TTree(1));
}It compiles fine with (2.074.0). |
|
@WalterBright as you like bugzilla and these seem to be individual issues, I opened two more issues, s.t. it can be tracked better: D-YAML: Issue 17505 - [REG2.075] @safe constructor requires the deconstructor to be safe as well |
|
This is also responsible for the regression in libasync where it fails with a nothrow constructor in a final class (that doesn't seem to have a dtor). Please advice how to proceed @WalterBright. |
Most popular excuse for breaking lots of production code 😄. |
It's not about me liking bugzilla. Bugzilla is the procedure we use for tracking bugs.
Thank you. |
Since there are some consequences to this PR with no obvious remedy, I suggest reverting it for the moment. |
Came to the same conclusion, see #6913. |
…ressions revert #6816 to due to excessive code breakage merged-on-behalf-of: Sebastian Wilzbach <sebi.wilzbach@gmail.com>

…objects/structs