Hello everyone -- I think I might have found a bug in cppcheck.

If I have this file:

#include <vector>
#include <iostream>

struct Event { double val; };

std::istream& operator>>(std::istream& in, Event& ev) { return in >> ev.val; }

std::istream& operator>>(std::istream& in, std::vector<Event>& evs)
{
    Event ev;
    while (in >> ev) evs.push_back(ev);
    return in;
}

int main(void)
{
    std::vector<Event> events;
    std::cin >> events;
    return 0;
}

and I do

cppcheck --enable=all test.cc

then it says:

[test.cc:6]: (style) The function 'operator>>' is never used.

but operator>>(std::istream&, Event&) is used in operator>>(std::istream&, std::vector<Event>&), which is in turn used in main. (Am I doing something wrong?)

Thanks in advance for your consideration.
All the best,

 

Last edit: Armando di Matteo 2021-02-17