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
fix Issue 13586 - Destructors not run when argument list evaluation throws #4078
Conversation
e255f68
to
48dac1f
Compare
This is necessary for reference counting to work reliably. |
@@ -774,7 +774,7 @@ STATIC void defstarkill() | |||
|
|||
#if 1 | |||
/* The following program fails for this: | |||
import core.stdc.stdio; | |||
import std.c.stdio; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A merge error I'd overlooked. Fixed.
48dac1f
to
a36c5c9
Compare
Why can't this be done entirely in the glue layer? Have you tested that the modifications to the ast don't break ctfe? Why is the new volatile stc necessary? Would it be necessary if this was all done in the glue layer instead of half in the frontend? |
Note the changes to how struct value arguments are handled in functionParameters(). Doing it in the glue layer would require awkward detection and undoing of those changes. The new code does it all in the front end. I thought about this for several days before deciding this was the most practical approach. Also, note that the glue layer still handles the actual insertion of destructor code. Also, the logic in the glue layer should be minimal. There's already too much in there. The idea with lowering in the front end is to reduce code and bugs by exploiting commonality through rewrite rules.
I don't know why it would. Why should it? Note that what this logic does is equivalent to:
which had better work in CTFE.
In order to prevent data flow optimizations to it, since the destructor code can be called out of line. This follows the optimizer logic that basically disables optimizations in finally blocks.
Yes. |
I can see for |
Ah, good point. Will check it out. Note that this is yet another reason for lowering rather than putting the logic in the glue layer! |
Yeah, or at least an argument for putting the entire thing in one layer. Sometimes a higher-level construct is easier to interpret than a lower one. |
a36c5c9
to
8e2d927
Compare
Added CTFE support. |
All destructor calls must be handled in AST for correct CTFE interpretation and temporary struct objects. |
@9rnsr those are separate issues and should not be handled by this PR. If every destructor issue was handled by one PR, then it would not be very reviewable. |
Sigh, another heisenbug in std.concurrency |
@@ -3351,6 +3351,90 @@ void test13303() | |||
|
|||
/**********************************/ | |||
|
|||
void test13586() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use hard tab.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
I'm not sure how the backend change is related with the front-end fix. I'd suggest to separate backend changes in its own commit with explanation commit log. |
Note that, the co-working of front-end and glue-layer will be harmful for CTFE. Actually, this PR does not fix issue 13586 during CTFE. @WalterBright, is that intended? |
8e2d927
to
aea25d6
Compare
This PR produces actual expressions in the dtor trees, and so also needed a bit of upgrading the back end to handle it. The front and back end changes need each other. Also, I don't know how to test for those other back end changes, as this PR caused a slightly different path to be taken through it which exposed a couple problems. They're simple enough fixes. |
Do you mean the insertion of dtors by e2ir.c?
As far as I can tell, CTFE has never handled destructors in expressions. This PR does not fix that, that is true, but it is a separate bug and should be handled separately. |
Current CTFE engine does not specially handle destructor calls those are inserted in glue layer. |
Auto-merge toggled on |
fix Issue 13586 - Destructors not run when argument list evaluation throws
This PR introduced a regression(ICE). |
This seems to have introduced another regression. |
This pull request introduced a regression: |
This pull request introduced a regression: |
By the PR dlang#4078, some preparation code has been inserted before a constructor call expression. Then, AssignExp has failed to recognize the ctor call form.
By the PR dlang#4078, some preparation code has been inserted before a constructor call expression. Then, `AssignExp` had failed to recognize the ctor call form.
https://issues.dlang.org/show_bug.cgi?id=13586