Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-29887

clang-4.0 warns about std::max(0u, variable) in geo code

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.5.11
    • Component/s: Geo
    • Labels:
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Sprint:
      Repl 2017-07-31

      Description

      This looks real, since that is almost certainly not what that code is actually trying to do:

      [454/2741 ( 16%) 28.503s] CXX build/ninja/mongo/db/exec/geo_near.o
      src/mongo/db/exec/geo_near.cpp:291:25: warning: taking the max of unsigned zero and a value is always equal to the other value [-Wmax-unsigned-zero]
              _currentLevel = std::max(0u, hashParams.bits - 1u);
                              ^~~~~~~~ ~~
      src/mongo/db/exec/geo_near.cpp:291:25: note: remove call to max function and unsigned zero argument
              _currentLevel = std::max(0u, hashParams.bits - 1u);
                              ^~~~~~~~ ~~~
      1 warning generated.
      [643/2741 ( 23%) 35.820s] CXX build/ninja/mongo/db/geo/r2_region_coverer.o
      src/mongo/db/geo/r2_region_coverer.cpp:73:17: warning: taking the max of unsigned zero and a value is always equal to the other value [-Wmax-unsigned-zero]
          _minLevel = max(0u, min(GeoHash::kMaxBits, minLevel));
                      ^~~ ~~
      src/mongo/db/geo/r2_region_coverer.cpp:73:17: note: remove call to max function and unsigned zero argument
          _minLevel = max(0u, min(GeoHash::kMaxBits, minLevel));
                      ^~~ ~~~
      src/mongo/db/geo/r2_region_coverer.cpp:79:17: warning: taking the max of unsigned zero and a value is always equal to the other value [-Wmax-unsigned-zero]
          _maxLevel = max(0u, min(GeoHash::kMaxBits, maxLevel));
                      ^~~ ~~
      src/mongo/db/geo/r2_region_coverer.cpp:79:17: note: remove call to max function and unsigned zero argument
          _maxLevel = max(0u, min(GeoHash::kMaxBits, maxLevel));
                      ^~~ ~~~
      2 warnings generated.
      

        Attachments

          Activity

            People

            Assignee:
            redbeard0531 Mathias Stearn
            Reporter:
            redbeard0531 Mathias Stearn
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: