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

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

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.5.11
    • Affects Version/s: None
    • Component/s: Geo
    • Fully Compatible
    • ALL
    • Repl 2017-07-31

      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.
      

            Assignee:
            mathias@mongodb.com Mathias Stearn
            Reporter:
            mathias@mongodb.com Mathias Stearn
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: