[llvm] Add clang::lifetimebound annotation to ArrayRef constructors. (PR #113547)
Gábor Horváth via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 24 05:28:22 PDT 2024
================
@@ -113,7 +115,8 @@ namespace llvm {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Winit-list-lifetime"
#endif
- constexpr /*implicit*/ ArrayRef(const std::initializer_list<T> &Vec)
+ constexpr /*implicit*/ ArrayRef(
+ const std::initializer_list<T> &Vec LLVM_LIFETIME_BOUND)
----------------
Xazax-hun wrote:
Hmm, actually, I am not sure if I'm super confident about this one.
Consider:
```
ArrayRef<int> ref({1, 2, 3, 4});
use(ref);
```
What would happen here? I wonder if this is actually safe despite the initializer list itself was a temporary and already destroyed when I invoke `use`.
https://github.com/llvm/llvm-project/pull/113547
More information about the llvm-commits
mailing list