llvm / llvm/llvm-project

[clang-tidy] detect `const`-qualified member functions which are not physically const

Open
#193,428 2 comments 0 reactions 0 assignees View on GitHub
check-request clang-tidy
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```cpp
struct SS
{
void fn();
};

struct S
{
void fn() const
{
m_ss->fn(); // allowed but breaks constness
}
private:
SS* m_ss;
};
```

The code above is valid but the constness of the called function is misleading.

This could be mitigated using [std::experimental::propagate_const](https://en.cppreference.com/cpp/experimental/propagate_const) for `S::m_ss`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.