[CDRIVER-757] Unsigned comparison in _mongoc_matcher_op_compare_new() is always true Created: 21/Jul/15  Updated: 12/Aug/15  Resolved: 07/Aug/15

Status: Closed
Project: C Driver
Component/s: libmongoc
Affects Version/s: 1.1.9
Fix Version/s: 1.2-beta0

Type: Bug Priority: Trivial - P5
Reporter: Jeremy Mikola Assignee: Jeremy Mikola
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

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.



 Comments   
Comment by Githook User [ 07/Aug/15 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@emptysquare.net'}

Message: Merge pull request #256 from jmikola/cdriver-757

CDRIVER-757: Suppress GCC warning for enum range check
Branch: 1.2.0-dev
https://github.com/mongodb/mongo-c-driver/commit/a48d38b252e6e77dd9c6b0245a48e2da1282c804

Comment by Githook User [ 07/Aug/15 ]

Author:

{u'username': u'jmikola', u'name': u'Jeremy Mikola', u'email': u'jmikola@gmail.com'}

Message: CDRIVER-757: Suppress GCC warning for enum range check

If the enum is compiled as an unsigned integer, this could trigger a type-limits warning (which might disrupt a -Werror build).
Branch: 1.2.0-dev
https://github.com/mongodb/mongo-c-driver/commit/8fe874241113c683d383acb20b19b7a667649f8a

Comment by Jeremy Mikola [ 30/Jul/15 ]

https://github.com/mongodb/mongo-c-driver/pull/256

Comment by Githook User [ 21/Jul/15 ]

Author:

{u'username': u'jmikola', u'name': u'Jeremy Mikola', u'email': u'jmikola@gmail.com'}

Message: Don't build with -Werror until CDRIVER-757 is resolved

Reverts 8087ab6d97970e1e9162ce6798e244127dc12bbf temporarily
Branch: master
https://github.com/10gen-labs/mongo-php-driver-prototype/commit/3051d3b18469751db1256559714ae99172613b01

Generated at Wed Feb 07 21:10:32 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.