Skip to content
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 compiler-inserted destructor call on shared objects #6752

Merged
merged 1 commit into from
May 17, 2017

Conversation

atilaneves
Copy link
Contributor

@atilaneves atilaneves commented May 7, 2017

Currently, a struct can be used as both shared and not when the constructor (and other functions) are templated on this. Defining a destructor breaks this because destructors can't be templated, and the non-shared destructor call on a shared this fails. This patch fixes this in a manner similar to how the compiler already treats destructor calls on immutable and const objects: by casting it away.

Since the compiler-generated destructor call is always scoped, only one thread is destroying it anyway.

@atilaneves atilaneves force-pushed the fix_shared_dtor branch 2 times, most recently from 8a5e658 to 9acc62c Compare May 10, 2017 12:34
shared or unshared. The constructor(s) can template on the type of
this to share implementations between shared and unqualified. The
destructor, however, is always a single function.
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is unnecessarily wordy. How about:

Enable calling destructors on shared objects. The destructor is always a single, non-overloaded function, and must serve both shared and non-shared objects.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@WalterBright WalterBright merged commit 27137dd into dlang:master May 17, 2017
@atilaneves atilaneves deleted the fix_shared_dtor branch January 5, 2018 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants