| Issue |
58093
|
| Summary |
`misc-const-correctness` not reported for pointer
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
firewave
|
The following reports nothing by default:
```cpp
#include <list>
class A
{
public:
void f() const;
};
extern void f(std::list<A> l)
{
std::list<A>::iterator it;
for(it = l.begin(); it != l.end(); ++it)
{
A* a = &(*it); // no warning
a->f();
}
}
```
This is also not reported if you completely remove the `f()` method.
If you enable `misc-const-correctness.WarnPointersAsValues` you get the warning on the pointer though:
```
<source>:14:9: warning: variable 'a' of type 'A *' can be declared 'const' [misc-const-correctness]
A* a = &(*it); // no warning
^
```
https://godbolt.org/z/KEbE6acvW
CC @JonasToth
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs