Skip to content

[CIR] Backport a fix for array element destruction order. #1823

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

Merged
merged 2 commits into from
Aug 15, 2025

Conversation

andykaylor
Copy link
Collaborator

Previously, when an array of destructible object went out of scope, the object destructors were called in the same order that they were constructed. This is incorrect. The objects should be destructed in reverse order. This change fixes that.

This fixes #1759

Previously, when an array of destructible object went out of scope, the
object destructors were called in the same order that they were constructed.
This is incorrect. The objects should be destructed in reverse order.
This change fixes that.

This fixes llvm#1759
I made a separate initial commit expanding the array-init-destroy.cpp
test checks to show the array destruction loop before my changes.
Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

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

Awesome, thanks!

@bcardosolopes bcardosolopes merged commit 222929a into llvm:main Aug 15, 2025
7 of 10 checks passed
@andykaylor andykaylor deleted the array-dtor-order branch August 15, 2025 22:42
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.

[CIR] Array elements are destructed in the wrong order
2 participants