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 Issue 16197 - Constructors/postblits and destructors don't match … #6774

Merged
merged 1 commit into from
May 22, 2017

Conversation

WalterBright
Copy link
Member

…up for array initialisation

@dlang-bot
Copy link
Contributor

Fix Bugzilla Description
16197 Constructors/postblits and destructors don't match up for array initialisation

static string r;
int x = -1;
this(this) { r ~= 'p'; printf("POSTBLIT %d\n", x++); }
~this() { r ~= 'd'; printf("DTOR %d\n" , x++); }
Copy link
Member

Choose a reason for hiding this comment

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

One unpleasant consequence of this idiom: calling ~= in a destructor causes reallocation which may cause garbage collection, which aborts the program...

Copy link
Member Author

Choose a reason for hiding this comment

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

True, but this is a test case only, and in this case the destructors are not being called by the gc. So it's all right here.

Copy link
Member

Choose a reason for hiding this comment

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

The problem is real - it did occur in some of Lucia's code.

Copy link
Member Author

@WalterBright WalterBright May 15, 2017

Choose a reason for hiding this comment

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

I know it is real, but not for this test case. It is only a problem when the GC is calling the destructors. That is not the case here, RAII is calling the destructor.

@dlang-bot dlang-bot merged commit ca5a785 into dlang:master May 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants