<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/111768>111768</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[[gsl::Pointer]] does not diagnose dangling-through-function-call
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pkasting
</td>
</tr>
</table>
<pre>
Similar to issue 99685.
Trivial forwarding helpers defeat the compiler's ability to notice -Wdangling-gsl issues. For example:
```
#include <string>
#include <utility>
struct [[gsl::Pointer]] S {
S(const std::string&);
};
template <typename T>
[[clang::always_inline]] S fwd(T&& t) {
return S(std::forward<T>(t));
}
[[maybe_unused]] static void f() {
[[maybe_unused]] S s1(std::string("123")); // Marked dangling, yay!
[[maybe_unused]] S s2(fwd(std::string("123"))); // Not marked dangling, boo :(
}
```
Live example: https://godbolt.org/z/T5q3zj6eo.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyElE1v4zYQhn_N6DKwIQ2tr4MOm7g-tUWBBOhxQYmUzF2KdMmRU--vL_SRxJt2u4JASSBnnpevOCNjNIPTuoH8AfJjIic--9BcvsrIxg1J69WteTKjsTIgezQxThrruqjyPaRHSD-t43MwVyMt9j68yKCMG_Cs7UWHiEr3WjLyWWPnx4uxOgCVEWVrrOHbnNV5Np3G3Z9KusEaN-yGaFdW3OPJB9R_y_FiNYiNB0W63esnCeM6OymNIB4jB-MGEL_81-TEC_Z9dhkjh6ljXFx4GKKdQeLTH9441gHyI-RHfEIoH9bliE9AVeddZIys1tUblgqgGsS2Esrj-_sysh4vVvIihm8X7eSo8fldzyKhs3LewZxW2hd5i5-Ns8bpNyn9iwKqnhdagQxU36sLmqfgFpFv8rZfA-JxgVE1B32UeqdzFTLKW6s_T26KWm3wyJJNh1dvFPZA1ffsH4Y9Yczu9bzaVQFRRgKI3vTgegGdgE74mwxftcLXswH0iDd5A8ped_t_SAKqVq9-Dt7YG_Z3zzj-G916j3Meqj669v2R_NVc9d2xxTPzJS6Bc_bBq9Zb3vswAJ2-AZ2e87_Ety-F9vtENULVopaJbrKSqjzLirROzk2ZUdorUVSHmqo0awuhStXnXVa2rexFmZiGUjpkaVoTpcWh3qtDrkQmZNrXoq2qEg6pHqWxe2uv4wxPliJrsiwriyqxstU2Lr2AyOmXtQRng_JjEpo5aNdOQ4RDak3k-J6GDdutifyofJTXca50VEYOzkf9ZuuOz8FPw3nXT65j492uk9YmU7DNB9cMn6d23_kR6DSzt8fuEvwX3THQaW0aQKdtS9eG_gkAAP__p0hvsQ">