llvm-project
llvm-project copied to clipboard
[clang-tidy] `misc-const-correctness` false positive
void func(int* ptr1)
{
int* ptr2 = ptr1;
*ptr2++ = 0;
}
warning: pointee of variable 'ptr2' of type 'int *' can be declared 'const' [misc-const-correctness]
3 | int* ptr2 = ptr1;
| ^
| const
The suggested code does not compile: https://godbolt.org/z/fGT9bvdza
Tested with 22.1.8
@llvm/issue-subscribers-clang-tidy
Author: Mia McMahill (electricbrass)
```c++
void func(int* ptr1)
{
int* ptr2 = ptr1;
*ptr2++ = 0;
}
```
warning: pointee of variable 'ptr2' of type 'int *' can be declared 'const' [misc-const-correctness]
3 | int* ptr2 = ptr1;
| ^
| const
The suggested code does not compile: https://godbolt.org/z/fGT9bvdza
Tested with 22.1.8
Also tested with 23.1.0-rc2. False positive is still present.
I can try this
godbolt repro https://godbolt.org/z/fxW8Ea1WT