clangir
clangir copied to clipboard
Destructors not called inside for loop
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.
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.