Skip to content

[clang-tidy] False positive readability-make-member-function-const when const overload already exists #64988

@chrchr-github

Description

@chrchr-github
#include <memory>

struct S {
    std::unique_ptr<int> u;
    int* get() { return u.get(); }
    const int* get() const { return u.get(); }
};
[<source>:5:10: warning: method 'get' can be made const [readability-make-member-function-const]]
    5 |     int* get() { return u.get(); }
      |          ^
      |                const

https://godbolt.org/z/sdKPco6Mn

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions