-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Attribute clang::lifetimebound produces no warning when assign temporary's address to pointer declared before. #54492
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
Labels
clang:diagnostics
New/improved warning or error message in Clang, but not in clang-tidy or static analyzer
Comments
hokein
added a commit
that referenced
this issue
Jul 1, 2024
… built-in pointer type (#96475) The lifetime bound warning in Clang currently only considers initializations. This patch extends the warning to include assignments. - **Support for assignments of built-in pointer types**: this is done is by reusing the existing statement-local implementation. Clang now warns if the pointer is assigned to a temporary object that being destoryed at the end of the full assignment expression. With this patch, we will detect more cases under the on-by-default diagnostic `-Wdangling`. I have added a new category for this specific diagnostic so that people can temporarily disable it if their codebase is not yet clean. This is the first step to address #63310, focusing only on pointer types. Support for C++ assignment operators will come in a follow-up patch. Fixes #54492
lravenclaw
pushed a commit
to lravenclaw/llvm-project
that referenced
this issue
Jul 3, 2024
… built-in pointer type (llvm#96475) The lifetime bound warning in Clang currently only considers initializations. This patch extends the warning to include assignments. - **Support for assignments of built-in pointer types**: this is done is by reusing the existing statement-local implementation. Clang now warns if the pointer is assigned to a temporary object that being destoryed at the end of the full assignment expression. With this patch, we will detect more cases under the on-by-default diagnostic `-Wdangling`. I have added a new category for this specific diagnostic so that people can temporarily disable it if their codebase is not yet clean. This is the first step to address llvm#63310, focusing only on pointer types. Support for C++ assignment operators will come in a follow-up patch. Fixes llvm#54492
kbluck
pushed a commit
to kbluck/llvm-project
that referenced
this issue
Jul 6, 2024
… built-in pointer type (llvm#96475) The lifetime bound warning in Clang currently only considers initializations. This patch extends the warning to include assignments. - **Support for assignments of built-in pointer types**: this is done is by reusing the existing statement-local implementation. Clang now warns if the pointer is assigned to a temporary object that being destoryed at the end of the full assignment expression. With this patch, we will detect more cases under the on-by-default diagnostic `-Wdangling`. I have added a new category for this specific diagnostic so that people can temporarily disable it if their codebase is not yet clean. This is the first step to address llvm#63310, focusing only on pointer types. Support for C++ assignment operators will come in a follow-up patch. Fixes llvm#54492
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:diagnostics
New/improved warning or error message in Clang, but not in clang-tidy or static analyzer
[[clang::lifetimebound]] could be used to provide some lifetime annotation to functions. In the statement of a pointer initialization, everything works fine. But in the statement of a pointer assignment, the desired warning can not be produced.
Here is the code sample:
Here is more code to illustrate this: https://godbolt.org/z/fhTPYTa1d
Is this intentional or a flaw of lifetime check?
The text was updated successfully, but these errors were encountered: