-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Object is not destructed while stack-unwinding #67074
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
Comments
Confirmed: https://godbolt.org/z/Eo9hzjPhe |
@llvm/issue-subscribers-c-1
I was solving cpp-quiz and got [question](https://cppquiz.org/quiz/question/323?result=OK&answer=bcad&did_answer=Answer) with followed code:
#include <iostream>
#include <stdexcept>
struct A {
A(char c) : c_(c) {}
~A() { std::cout << c_; }
char c_;
};
struct Y { ~Y() noexcept(false) { throw std::runtime_error(""); } };
A f() {
try {
A a('a');
Y y;
A b('b');
return {'c'};
} catch (...) {
}
return {'d'};
}
int main()
{
f();
} According to standard, program's output should be
|
Useful to note this example comes from except.ctor p2. I don't know where we would need to fix this but I am hoping @zygoloid does NB: I think the last lifetimes issue I saw was: #65282 |
Duplicate of #12658 |
@llvm/issue-subscribers-clang-codegen
I was solving cpp-quiz and got [question](https://cppquiz.org/quiz/question/323?result=OK&answer=bcad&did_answer=Answer) with followed code:
#include <iostream>
#include <stdexcept>
struct A {
A(char c) : c_(c) {}
~A() { std::cout << c_; }
char c_;
};
struct Y { ~Y() noexcept(false) { throw std::runtime_error(""); } };
A f() {
try {
A a('a');
Y y;
A b('b');
return {'c'};
} catch (...) {
}
return {'d'};
}
int main()
{
f();
} According to standard, program's output should be
|
I was solving cpp-quiz and got question with followed code:
According to standard, program's output should be
bcad
. But clang-18 produces justbad
. I performed some tests and found out that A-object with'c'
value was never destructed. Order of construction and destruction that I get is:The text was updated successfully, but these errors were encountered: