Issue 98004
Summary Thread safety analysis and temporaries
Labels new issue
Assignees
Reporter leonid-s-usov
    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);
    }
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to