[SERVER-31592] Investigate MSVC warning in GeoHashConverter code Created: 16/Oct/17  Updated: 06/Dec/22  Resolved: 27/Oct/17

Status: Closed
Project: Core Server
Component/s: Geo
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Mark Benvenuto Assignee: Backlog - Query Team (Inactive)
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query
Operating System: ALL
Participants:

 Description   

The sizeEdge function triggered a warning in MSVC. It needs to be investigated to verify if the code warning should be ignored. The code was introduced in SERVER-15576.

// Relative error = epsilon_(max-min). ldexp() is just a direct translation to
// floating point exponent, and should be exact.
double GeoHashConverter::sizeEdge(unsigned level) const {
    invariant(level >= 0);
    invariant((int)level <= _params.bits);
#pragma warning(push) 
// C4146: unary minus operator applied to unsigned type, result still unsigned
#pragma warning(disable : 4146)
    return ldexp(_params.max - _params.min, -level);
#pragma warning(pop)
}



 Comments   
Comment by Charlie Swanson [ 27/Oct/17 ]

Per Siyuan's comment the Query team doesn't think there's actually a problem here.

Comment by Siyuan Zhou [ 20/Oct/17 ]

If I understand correctly, the warning is caused by -level, which applies unary minus operator to an unsigned type. The level should be at most 32, so this operator should be safe. I think we can use static_cast to get rid of the waring.

Comment by Ian Whalen (Inactive) [ 20/Oct/17 ]

siyuan.zhou at a glance do you know why this is being negated? if not we can dig deeper.

Generated at Thu Feb 08 04:27:33 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.