-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Open
Labels
clang-tidyconfirmedVerified by a second partyVerified by a second partyfalse-positiveWarning fires when it should notWarning fires when it should not
Description
Considering:
#include <string_view>
struct Label {
virtual ~Label();
};
bool operator==(std::string_view, Label const&);
auto f() {
std::string_view s{"aa"};
return s == Label{};
}
clang-tidy -checks=readability-container-size-empty
emits the following incorrect warning:
<source>:11:12: warning: the 'empty' method should be used to check for emptiness instead of comparing to an empty object [readability-container-size-empty]
11 | return s == Label{};
| ^~~~~~~~~~~~
| s.empty()
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/string_view:251:7: note: method 'basic_string_view'::empty() defined here
251 | empty() const noexcept
| ^
1 warning generated.
Metadata
Metadata
Assignees
Labels
clang-tidyconfirmedVerified by a second partyVerified by a second partyfalse-positiveWarning fires when it should notWarning fires when it should not