[SERVER-31310] Use SafeInt functions for MSVC overflow detection Created: 28/Sep/17  Updated: 30/Oct/23  Resolved: 05/Sep/19

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 4.3.1

Type: Improvement Priority: Major - P3
Reporter: Mathias Stearn Assignee: Billy Donahue
Resolution: Fixed Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-43032 simplify platform/overflow_arithmetic.h Closed
Backwards Compatibility: Fully Compatible
Sprint: Dev Tools 2019-07-01, Dev Tools 2019-08-26, Dev Tools 2019-09-09
Participants:

 Description   

We can't use the signed specializations on MSVC2015 due to a typo in the library. That typo looks like it was fixed in MSVC2017 so we should try again after upgrading.

Switching to SafeInt functions allows us to use templated overflow detection functions rather than supporting a fixed set of types, encoded into the function names, and providing an separate implementation for every one.



 Comments   
Comment by Billy Donahue [ 05/Sep/19 ]

Our API is now a set of overloads on 3 functions:

mongo::overflow::

{mul,add,sub}

.

Internally those are using MSVC SafeInt functions, but there's not a hard need to encode the typenames into the API functions. The API can internally sort out which SafeInt functions to call. Anyway, the internals might still benefit from an upgrade, it's just that the API is now only 3 names.

Comment by Andrew Morrow (Inactive) [ 10/Jul/19 ]

Moving to Q3 quick wins for dev tools. I think this is a straightforward refactoring and probably worth doing.

Comment by Andrew Morrow (Inactive) [ 22/Jun/19 ]

redbeard0531 - Did the work done under SERVER-26906 accomplish the goals of this ticket? See https://github.com/mongodb/mongo/commit/a587fc4fe1e0c051b8f534d6c2efad35314a899c

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