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
[[clang::always_destroy]] attribute while emitting exit-time-destructors diagnostic #68686
Comments
I think we just need to add a check for llvm-project/clang/lib/Sema/SemaDeclCXX.cpp Lines 16119 to 16121 in feea5db
wdyt @AaronBallman |
Yes, I think that should do it, however, it's worth noting that there's some confusion here with our diagnostics: https://godbolt.org/z/nsMhGrxGq I think that attribute should silence both diagnostics, but... why do we have two diagnostics to tell the user the same information? |
@AaronBallman. There is not much about [global constructors] (https://clang.llvm.org/docs/DiagnosticsReference.html#wglobal-constructors) diagnostics in the Diagnostics Reference at the moment. |
Also |
Yeah, it seems this feature was added long ago: 47e40931 and there's no review or explanation as to why we wanted to issue the same diagnostic twice here. :-/ |
Compiling this code with the -Wexit-time-desctuctors diagnostic enabled will raise the warning, for good reason.
here is the output
However, being happy with the destructor call on exit time, not only do I want to silence the warning but to flag the variable accordingly. For that I add the [[clang::always_destroy]] attribute to the static variable.
This is meant to tell the compiler that I am aware of the exit time destructor and willing to pay the price, and properly release the resource.
The [[always_destroy]] attibute documentation states that it
I believe adding explicitly the attribute should be enough to stop the compiler from emitting the diagnostic, but it is not the case.
The text was updated successfully, but these errors were encountered: