<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/111680>111680</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang still doesn't catch dangling case of Container of pointer-like element
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:diagnostics
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
usx95
</td>
</tr>
</table>
<pre>
These cases are not caught by clang:
https://godbolt.org/z/4cTs8aer4
```cpp
#include <optional>
#include <set>
#include <string>
#include <string_view>
#include <vector>
std::string GetString() { return "foo"; }
void Test() {
// Bad.
std::set<std::string_view> s = {GetString(), GetString()};
std::vector<std::string_view> v = {GetString(), GetString()};
s = {GetString(), GetString()};
// Good.
std::optional<std::string_view> t2 = std::string();
}
```
cc: @hokein
related bug which was closed: https://github.com/llvm/llvm-project/issues/100526
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVE1v4zgM_TXyhWggy98HH5pk3R-wvS9kibW1VaVAotPt_vqB4qQZpJM5dABDhvhMvvdoUTJGMznEnlVbVu0zudDsQ7_E_7oqG73-6J9njAhKRowgA4LzBEou00wwfoCy0k2seGR8z_h5nYkOMcXEwMQweT16SxsfJiaG_5kYSvUcW4mhPCfVfH3U4XCOiMI4ZReNwIqdP5DxTlpW_PUrOCLdQyiYJO434D9Hg-93vjiiIh-u4GmNpJOz4nHNhyekv1ca0TLRAWu2EJCW4IAJ8eI9E4IVW2DN_ucyR280PGOka9oKAACsfYOt1Jtz8MqazO5uRFxMQARW7FOtG1VM7G6FJj3F9rb8xfJdhuM3GQC-K-5LW568_9qX6xm5K53EScANfCb8ZPv8TZdDuW6VYsUjsJLP_hWNgzUa0EpCDeMywfts1AzvMoKyPmIigZtBMDQv40b5NyYGa4-X18Mh-H9RERODiXHByMSQc16JOtN9obuikxn2eSPass1b3mZzL8uXrqtK3ai65nXTYdOOWhSNrGQ1Cq4y0wsuypzzLi8qztuN4LXK27bUddk0eV2zkuObNHaTFKTZzE7cfZ7ndcszK0e08XQpCHGZcW3k5Hwko2I61dU-C_3JwLhMkZXcmkjxWpAMWex3KRkiGWtBe4yOiSZdIKRm0NJNNk1Rul3Av8DOO5LGYUibgzeOMDxY84qAFt_QUbYE2_9BW1d3x178CAAA__-VV3fg">