<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/98004>98004</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Thread safety analysis and temporaries
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
leonid-s-usov
</td>
</tr>
</table>
<pre>
Hi!
It appears that when temporaries are involved, the analyzer ignores the destructors, which causes the static analysis warnings. Please see this compiler explorer example: https://godbolt.org/z/r4fa5Kd7r
I am trying to create a movable scoped lockable, but the issue is preventing me from being able to generically return and move-construct the scoped objects.
There are two issues, actually. One is the temporary object whose destructor isn't considered, and other is a simple wrapper struct, where the member in the struct is scoped lockable. Both cases result in a warning.
```
std::cout << "=== temporary destructor ignored" << std::endl;
{
ValueReader reader(&value);
auto val = [reader2 = ValueReader(std::move(reader))]() mutable {
auto reader3 = std::move(reader2);
std::cout << "in a lambda 2" << std::endl;
return reader3.value();
}();
}
```
```
std::cout << "=== member destructor ignored" << std::endl;
{
ValueReader reader(&value);
struct Wrapper {
ValueReader wrapped_reader;
};
auto wr = Wrapper { std::move(reader) };
assert(wr.wrapped_reader.value() == value.value);
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVV-Pq7YT_TTmZRQEJizkgYfdjaLfT31oVV21j9WAJ8GtsZFtkuZ--sqGbMg2t-ofC4XYMGeO5xzG6Jw8aaKGlW-s3Cc4-d7YRpHRUmzcZnLmnLRGXJv_ScZzlu1Z9jr__t8DjiOhdeB79HDpSYOnYTQWrSQHaAmkPht1JsH4O_ieADWq61eyIE_aWHJxUZDzduq8sS68d-ll10OHk1ueO49ednOskw4uaLXUJ5fCD4rQETgi8L100JlhlIos0O-jMjb-wWFUxIpX6L0fHSteGT8wfjgZ0RrlU2NPjB--Mn6w2yOW34nKPuwScABvr1KfwBvoLKEnQBjMGVtF4DozkgBlut_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