Issue 164852
Summary [clang-tidy] readability-container-data-pointer suggests incorrect fix for container held by pointer
Labels bug, clang-tidy
Assignees
Reporter LegalizeAdulthood
    compiler explorer reproducer here: https://godbolt.org/z/nM3TPeKhj

The following code:
```
#include <memory>
#include <vector>

void g(int *p);

void f()
{
    std::unique_ptr<std::vector<int>> p{std::make_unique<std::vector<int>>()};
    g(&(*p)[0]);
}
```

is correctly flagged at the call site to `g()`, but the fixit suggested is incorrect: `g(*p.data())` because the `.` binds tighter than the `*`.  The correct fixit should be `g((*p).data())`.

The failure can be reproduced by adding `--fix` to the compiler explorer options for clang-tidy.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to