safans - 4 days ago

Hi, I found a false negative regarding the rule AccessMoved.

In the following program, cppcheck should have reported a AccessMoved warning at line 5 or 6 because static_cast<std::string&&>(s) is equivalent to std::move(s). However, actually it reported no warnings. So I believe this is a false negative.

void foo(std::string);
int main()
{
    std::string s = "deadbeef";
    foo(static_cast<std::string&&>(s));
    std::cout << s << std::endl;
    return 0;
}

Version: 2.19.0

 

Last edit: safans 4 days ago