| Issue |
177798
|
| Summary |
[[clang::lifetimebound]] is ignored when added to template method definition, but not to its declaration
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
ddkilzer
|
`[[clang::lifetimebound]]` is ignored when added to template method definition, but not to its declaration.
```cpp
template<typename T>
class StringTemplateB {
public:
const T* data() const; // No attribute
private:
T buffer[32];
public:
StringTemplateB() {
if constexpr (std::is_same_v<T, char>) {
std::strcpy(buffer, "hello");
} else {
buffer[0] = T{};
}
}
};
template<typename T>
inline const T* StringTemplateB<T>::data() const [[clang::lifetimebound]] {
return buffer;
}
const auto ptrTB = StringTemplateB<char>().data(); // Missing warning
```
The Godbolt test should show 9 `-Wdangling` warnings, but currently only shows 8 warnings (missing warning for `ptrTB`): https://godbolt.org/z/ra5avj8e4
Neither `-Wlifetime-safety` nor `-Wlifetime-safety-suggestions` from Issue #176821 warns about this, either. (Cc @usx95)
This is a follow-up from Issue #175391.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs