-
Notifications
You must be signed in to change notification settings - Fork 13.4k
dtor of return value isn't run if dtor of a scoped variable throws and is caught in the same function #73024
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
@llvm/issue-subscribers-clang-codegen Author: None (kelbon)
https://godbolt.org/z/nYnvv3EEf
Code without address sanitizer to avoid false positive: https://godbolt.org/z/qbxMG659h #include <vector>
inline bool g = false;
struct X {
int i = 0;
~X() {
if (i == 1) g = true;
}
};
struct Y {
~Y() noexcept(false) { throw 0; }
};
X f() {
try {
Y y;
return X{1};
} catch (...) {
}
return X{};
}
int main() {
f();
if (!g)
return 4;
}
|
Can't say I understand the non-asan failure. It looks correct, but I'm probably misunderstanding... In https://godbolt.org/z/qxTjva39r - the Y dtor runs, so |
No, its not correct, value was constructed, but not destroyed, basic RAII broken |
Yeah, fair enough, that last one seems unambiguously buggy to me. |
I believe this is a duplicate of: #12658 |
https://godbolt.org/z/nYnvv3EEf
Code without address sanitizer to avoid false positive:
https://godbolt.org/z/qbxMG659h
The text was updated successfully, but these errors were encountered: