Introduce til namespaces shorthands for the chromium safe math#4278
Introduce til namespaces shorthands for the chromium safe math#4278skyline75489 wants to merge 1 commit intomicrosoft:masterfrom
til namespaces shorthands for the chromium safe math#4278Conversation
|
Firstly at line 46 of static constexpr bool Do(Src value) {
// Force a compile failure if instantiated.
return CheckOnFailure::template HandleFailure<bool>();
}Secondly if this is how we handle safe math in the future, it'd probably look like this:: - THROW_IF_FAILED(ShortAdd(newLeft, delta.X, &newLeft));
+ newLeft = (til::checked_numeric<SHORT>(newLeft) + til::checked_numeric<SHORT>(delta.X)).ValueOrDie();Yeah ... I know, right. Doesn't look so good. |
Go to src/inc/LibraryIncludes.h. Change to We're not afraid of suppressing warnings from dependent libraries. We really just want the warning/static analysis for our code.
I was thinking it'd be more like I see a base::CheckAdd template that appears to work that way. Which is significantly less ugly. Though if they're all just in the |
31c012c to
92e766c
Compare
|
If we directly use newLeft = base::CheckAdd(newLeft, delta.X).ValueOrDie();I'm really not a fan of the newLeft = til::check_add(newLeft, delta.X); |
92e766c to
5cd06ff
Compare
I see your point for The could probably just hold the checked value as an The one thing I could think might be remaining is that there isn't really a As for It will just assign straight out to the base type, not keep it wrapped in the So in total.... despite my earlier thought that we should wrap some of these in |
|
I'm still rooting for adding til namespace instead of using base from third party code. I’m gonna leave this PR here. Feel free to close it. It is a draft anyway. |
Alright. Not saying I won't change my mind. I do that frequently. Thanks. |
Summary of the Pull Request
This does not work yet.
References
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed