<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/120543>120543</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Diagnose dangling issues on member field access
</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>
hokein
</td>
</tr>
</table>
<pre>
We have some supports in member field access for references (#81589). It would be good to diagnose on the view types, see https://godbolt.org/z/zbx8hPera
```
#include <string_view>
#include <string>
struct S2 {
std::string s2;
};
struct Q3 {
const S2* get() const [[clang::lifetimebound]];
};
void test() {
auto& t = Q3().get()->s2; //dangling, clang diagnoses it.
std::string_view v = Q3().get()->s2; // dangling, clang doesn't diagnose it, bad.
}
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMU0GPszYQ_TXDZRRkxhDgwCGbbKTeuuqhx8rgAdwaHGGTbfrrKydkd1vtJ33SIBAPv_fmDaO8N8PM3EDxAsUpUWsY3dKM7i82c9I6fWt-ZxzVldG7idGvl4tbgkcz48RTywv2hq1G1XXsPfZuwYV7Xnju2CNQBSSrrKhqoDrFXwK-u9VqbBkH5zQGh9qoYXae0c0YRsar4XcMtwt7oCN6ZhxDuHiQB6Az0HlwunU2pG4ZgM7_xKv9uxp_5UWBOMTai63EAUiaubOrZgR59GEx8_BHVAD5-gN4Q8TBh2XtAv5GCOULiAOiDzrakIfHl-gJZESgPD0etiNv8uNI52YfOYAOOHC4B1Jvb--Zv3RWRdFIa03PwUzcunXWUJxi_Vfg6ozGwP5J9JRRa3BAewwI8oRv8gGnH4o7kK93t_gIUat5sLFZOuLdwMcYPJqQftftPTa8_qQAfqPg2M9AZfgcuQkRbpVOtya_TC_RjdS1rFXCTVbKfC9EXlbJ2Ki84pp03xZtWwku96qvizzrJCmZ9aQT05CgPKOsFjWVRZVynymxz3S57wuRtyXkgidlbGrtdYo_UmK8X7nJSBS5TKxq2fr7ShA9x7N5DqbzQAR0_IJNPLnltvOq53CLaHFKliaS79p18JALa3zwn3LBBMvN6RnDMyu82_BxE75ZrmRdbPO_XTBhXNu0cxPQObJvt91lcX9yF4DOD0qg89bctaF_AwAA__8dcjWN">