<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/56749>56749</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`misc-const-correctness` suggests `const` on pointer to array even if disabled
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
firewave
</td>
</tr>
</table>
<pre>
```cpp
static void f()
{
const char * a[] = {"", ""};
}
```
```
<source>:3:5: warning: variable 'a' of type 'const char *[2]' can be declared 'const' [misc-const-correctness]
const char * a[] = {"", ""};
^
const
```
https://godbolt.org/z/e646rPo99
According to https://clang.llvm.org/extra/clang-tidy/checks/misc/const-correctness.html `WarnPointersAsValues` is disabled by default. It seems this option is not being used when it applies to arrays (that's the only case I have seen it with).
Also the fix-it hint is placed on the existing `const` which makes this look like a false positive (see the "swiggle" in godbolt). I think that actually should to point before the `a` instead.
The documentation of `WarnPointersAsValues` could be bit more straightforward and including a proper before/after example would also be helpful. I knew what it was supposed to do but I really didn't get it from the documentation.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVE2TmzgQ_TVw6RqXLQYbDhw8maQqtxxSu2chNaC1QJQk7HF-_T5hz2Sdyu5pKWTro9X93utuWqevTbbf3l41z9n2NdseQ5TRKDo7o6nLRJWJ-naQHV5uE8Kj3BQiqUF6ysSRZFa-ZOUrZQUG7IRY3090nx1es-Ll3c3rffIe-r787WbxKbjFK86Kz1lxLDBKDLpIP5mpT9Oz9Ea2lhHqIDHIdRSv87p-RAmMAiCTjZITtUyalZWe9YdtOoPZaIJ6Wjfw6z2rOHEI6e7_IEC6nZWffy4enhuM32kxxDgHMM7EF7y9062zceN8j9UPDN4_7_03V9f_1POoQEBDKoqOHj2A-tRvrD2Pdyf8Fr18P3iKRl_TYmB1CpgkTdL6V1U2QxwtAeWfyMk3Z6bIPhzDH9IuHLBNJpA2IaVIU3u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