Tautological Constant Comparisons errors should be detected by required builders

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • DevProd Build
    • Fully Compatible
    • 200
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Our MacOS builders detect errors via -Wtautological-constant-out-of-range-compare with this signature:

      [2026/03/25 02:57:58.845] src/mongo/bson/column/bsoncolumn_util.cpp:37:33: error: result of comparison of constant -14 with expression of type 'uint8_t' (aka 'unsigned char') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
      [2026/03/25 02:57:58.845]    37 |     BSONType rootType = control == bsoncolumn::kInterleavedStartArrayRootControlByte
      [2026/03/25 02:57:58.845]       |                         ~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      [2026/03/25 02:57:58.845] src/mongo/bson/column/bsoncolumn_util.cpp:42:17: error: result of comparison of constant -14 with expression of type 'uint8_t' (aka 'unsigned char') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
      [2026/03/25 02:57:58.845]    42 |         control == bsoncolumn::kInterleavedStartArrayRootControlByte;
      [2026/03/25 02:57:58.846]       |         ~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      [2026/03/25 02:57:58.846] src/mongo/bson/column/bsoncolumn_util.cpp:41:39: error: result of comparison of constant -15 with expression of type 'uint8_t' (aka 'unsigned char') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
      [2026/03/25 02:57:58.846]    41 |     bool traverseIntoArrays = control == bsoncolumn::kInterleavedStartControlByte ||
      [2026/03/25 02:57:58.846]       |                               ~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      

      We should be able to detect these kind of programming errors via our required builders.

            Assignee:
            Zack Winter
            Reporter:
            Henrik Edin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: