https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114104

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-02-25

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This bug means we fail to diagnose this example (courtesy of Stephan T.
Lavavej):

#include <print>
#include <vector>
using namespace std;

int main() {
    vector<int> x{10, 20, 30};
    vector<int> y{11, 22, 33, 44};

    for (auto i = x.begin(), j = y.begin(); i != x.end(), j != y.end(); ++i,
++j) {
        println("{} {}", *i, *j);
    }
}

The loop condition should use && between the two expressions but it uses a
comma instead. Even though operator== for vector::iterator is marked nodiscard,
we fail to warn that i != x.end() is discarded.

Reply via email to