Skip to content

[clang-tidy] bugprone-unused-return-value false positive will matching assignment #84480

@HerrCai0907

Description

@HerrCai0907

It seems like this is a bigger issue.

If you use ::.* for CheckedFunctions to match all functions it will report the warning on every assignment (= and +=) regardless of type.

Originally posted by @firewave in #84314 (comment)

Here's an example:

#include <string>

class C {
public:
    void setS(const char* s) {
        mS = s;
    }
private:
    std::string mS;
};
test.cpp:6:9: error: the value returned by this function should not be disregarded; neglecting it may lead to errors [bugprone-unused-return-value,-warnings-as-errors]
    6 |         mSt = s;
      |         ^~~~~~~

(No godbolt link as I could not figure out how to make the passing of the option work)

Originally posted by @firewave in #84314 (comment)

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