Menu

#28 False positive on "mismatch" enumeration

v1.0 (example)
open
nobody
None
5
2025-06-06
2025-06-06
Flash
No

I have an enumeration that has a value mismatch. Every reference to this value yields an obtuse warning:

[1] (buffer) mismatch:Function does not check the second iterator for over-read conditions (CWE-126). This functino is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it.

I'm guessing the warning is related to std::mismatch() but the whole point of namespace scoping is to disambiguate commonly used names.

class Foo {
public:
    enum MatchState {
        invalid,
        ignored,
        exact_match,
        near_match,
        mismatch,
        match_new,
        mismatch_new,
    };
};

Discussion


Log in to post a comment.

MongoDB Logo MongoDB
Gen AI apps are built with MongoDB Atlas
Atlas offers built-in vector search and global availability across 125+ regions. Start building AI apps faster, all in one place.