Issue 174269
Summary [clang-tidy] False positive `readability-make-member-function-const` for `union`
Labels clang-tidy
Assignees
Reporter eisenwave
    https://godbolt.org/z/3dYM7vqo1
```cpp
struct S {
    union { int* resource; };
    int& get() { return *resource; }
 const int& get() const { return *resource; }
};
```
```
<source>:3:10: warning: method 'get' can be made const [readability-make-member-function-const]
    3 |     int& get() { return *resource; }
      |          ^
      |                const
1 warning generated.
```

Moving `resource` out of `union` makes the diagnostic go away, which appears to be the intended behavior.

On top of `union` preventing whatever would have suppressed the diagnostic otherwise, it also seems nonsensical to tell the user they could make a function `const` when there already exists another overload that is `const`; adding `const` would just result in a compiler error.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to