<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/112349>112349</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
No dangling diagnostic with lifetimebound when function return reference or const ref.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:diagnostics,
clang:memory-safety
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
usx95
</td>
</tr>
</table>
<pre>
https://godbolt.org/z/azP6MdGda
```cpp
struct S {};
struct T {};
S foo1(const T& a [[clang::lifetimebound]]);
S& foo2(const T& a [[clang::lifetimebound]]);
const S& foo3(const T& a [[clang::lifetimebound]]);
void use() {
S x = foo1(T{}); // No warning. Bad.
S y = foo2(T{}); // No warning. Bad.
S& y1 = foo2(T{}); // Warning. Good.
S z = foo3(T{}); // No warning. Bad.
const S& z2 = foo3(T{}); // Warning. Good.
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyklM9uozAQxp9muIwa4TGEcODQLKKnrVZKpT0b2xCviB3Zpm3y9Csg2f7Zqj0UWbY01vz4-GYGEYLprdYV5FvI60SMce98NYbnMk9ap07VPsZjAH4L1AA1vVOtG-LK-R6oOQM14vxr_VPdKQFpDektrNNlyeNxiYToRxlxh1BsoaiBb9_EH97Hl32HnXMMaCOdDREfgNYocFa5lYOw_SSJ3w6m09EcdOtGqyCvp0XlP9ZuSuuco--CluQrjn8Xt-yPzigcgwbaAJWzD3McEXGHzwi8vrrwcDFpZiAuxcB7h0_CW2P7FW6FWr2GL5DTFUL_Q77AzIDp807sE8gF8fuaf-fcRzrOVwT_SMfyfKnmVRHO9AnwM01F_a5PE1VxVfJSJLpiBW3Kkm8YS_ZVJ1XWyZSts02uWatzVhRF12WFzspOCZ2YilLKWMpyRinn6Spv5abluZRpQankBWSpPggzrIbh8TCNTGJCGHXFGPGsTAbR6iHMk0d07R1lRG9diEYGIAL68eruoA_On26C6HQ8Tbd5nfhqgt-0Yx8gSwcTYnh5XTRx0NW9QyVsPxjb4wsen0zc45s-xae9ttiNVkbjLHodRz8dnfbaSo3OX0rgdbdKRj-8_zmYuB_blXQHoGYScTlujt790TICNbMBAai5ePBY0d8AAAD__96QR7U">