Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-757

Unsigned comparison in _mongoc_matcher_op_compare_new() is always true

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Trivial - P5 Trivial - P5
    • 1.2-beta0
    • Affects Version/s: 1.1.9
    • Component/s: libmongoc
    • None

      The following error recently popped up in the PHPC builds after bjori added -Werror to our build flags (here):

      home/travis/build/10gen-labs/mongo-php-driver-prototype/src/libmongoc/src/mongoc/mongoc-matcher-op.c:165:4: error: comparison of unsigned expression >= 0 is always true [-Werror=type-limits]

      I traced this back to this commit.

      While we could suppress this error with [-Wno-type-limits], that might hide other errors, too. Some ideas tossed around in this thread include adding an unused negative value to the enum to force a signed type to be used (which seems noisy) or to for a signed cast before the comparison. Alternatively, we can just do without the >= MONGOC_MATCHER_OPCODE_EQ part of the assertion if we want to rely on the enum being unsigned and MONGOC_MATCHER_OPCODE_EQ being zero.

            Assignee:
            jmikola@mongodb.com Jeremy Mikola
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: