Skip to content

Fix bug GH-14456: Attempting to initialize class with private constructor calls destructor #14469

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

Closed
wants to merge 2 commits into from

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Jun 4, 2024

No description provided.

Copy link
Member

@dstogov dstogov left a comment

Choose a reason for hiding this comment

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

I'm not completely sure if the existing behavior was done on purpose or not.
The proposed change looks right to me, and I don't object against the PR.
However, some user code may relay on the existing behavior.

@iluuu1994 please take a final look.

Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

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

It does seem to me that the destructor should not be called in this case. The class may make assumptions about fields being initialized. Hence, calling the destructor might be unsafe. I'm not sure how much this matters, given that this code already throws. Either way, I think not calling the destructor seems more reasonable.

@Girgias Girgias closed this in cdb7677 Jun 6, 2024
@Girgias Girgias deleted the fix-gh14456 branch June 6, 2024 14:52
@iluuu1994
Copy link
Member

Oh, I missed that this was proposed for 8.2. I would have preferred to merge it for master and document the change. But I hope it doesn't matter in practice.

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.

3 participants