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

Destructors not called inside for loop #1139

Open
smeenai opened this issue Nov 19, 2024 · 1 comment
Open

Destructors not called inside for loop #1139

smeenai opened this issue Nov 19, 2024 · 1 comment
Assignees

Comments

@smeenai
Copy link
Collaborator

smeenai commented Nov 19, 2024

https://godbolt.org/z/bdqM4ccxf demonstrates the issue. For the following code:

#include <stdio.h>
struct S { ~S() { puts("~S"); } };
int main() {
    for (int i = 0; i < 4; i++) {
        S s;
    }
}

CIR calls the destructor at the end of the for loop (including when exiting it with a break) instead of inside it. This is kinda like the opposite of #348; in this case, the destructor is called when jumping out of a scope but not when exiting and resuming it normally.

@bcardosolopes
Copy link
Member

Yea, we have a list of other issues where we are missing dtors, if no one beats me to it, I'll do this one.

@bcardosolopes bcardosolopes self-assigned this Nov 22, 2024
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

No branches or pull requests

2 participants