Issue 79083
Summary [libc++] std::shared_ptr::reset() should catch being reset to its own pointer
Labels libc++, hardening
Assignees var-const
Reporter ldionne
    https://compiler-explorer.com/z/s58er4o4z

```c++
#include <memory>

int main() {
    auto p = std::make_shared<int>(42);
 p.reset(p.get()); // Incorrect use of reset
}
```

libstdc++ catches that with

```
Assertion '__p == nullptr || __p != _M_ptr' failed.
```

I think it would be really easy to add this check in libc++ too.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to