-
-
Notifications
You must be signed in to change notification settings - Fork 704
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 23561 - std.typecons.Unique!struct does not destroy struct … #8651
Conversation
|
Thanks for your pull request and interest in making D better, @ntrel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + phobos#8651" |
std/typecons.d
Outdated
| ~this() @trusted | ||
| { | ||
| // context pointer doesn't exist when GC calls | ||
| if (&i > cast(void*) 1024) |
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.
Is there a better way of checking for this?
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 is this needed?
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.
destroy calls the destructor first, before nullifying the context pointer (I think). Then when the GC calls the destructor it segfaults when accessing i to increment it, because the context pointer is null.
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.
This works for me:
| if (&i > cast(void*) 1024) | |
| if (this !is typeof(this).init) |
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.
OK. I asked on the learn forum for a way that works well in general and @aG0aep6G suggested using tupleof[$-1], so I've used tupleof[0] as tupleof.length here is 1.
|
Squash the commits before merge. |
|
@ljmf00 Razvan has used |
|
Added a separate changelog with a note about the GC calling the destructor too: #8654. |
|
This PR caused a regression https://issues.dlang.org/show_bug.cgi?id=23723 |
…instance