llvm-project
llvm-project copied to clipboard
[clang-tidy] `misc-const-correctness` false positive
The following suggestion does not compile:
void func(int* p) {
int* r = p;
int* v = p;
*(r = v) = 0;
}
<source>:2:5: warning: pointee of variable 'r' of type 'int *' can be declared 'const' [misc-const-correctness]
2 | int* r = p;
| ^
| const
Godbolt (trunk): https://godbolt.org/z/3o8qnEKs3
@llvm/issue-subscribers-clang-tidy
Author: David Meng (davidmenggx)
The following suggestion does not compile:
```cpp
void func(int* p) {
int* r = p;
int* v = p;
*(r = v) = 0;
}
```
```
<source>:2:5: warning: pointee of variable 'r' of type 'int *' can be declared 'const' [misc-const-correctness]
2 | int* r = p;
| ^
| const
```
Godbolt (trunk): https://godbolt.org/z/3o8qnEKs3