New issue
Advanced search Search tips

Issue 667097 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Jun 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Bug



Sign in to add a comment

Add variadic convenience functions for base/numerics

Project Member Reported by jsc...@chromium.org, Nov 20 2016

Issue description

These would just perform the standard operations and return a CheckedNumeric as a result. So, something like:

auto result = CheckedAdd(x, 3, CheckedSub(y, 2), CheckedMul(z, 12));

 
Project Member

Comment 1 by bugdroid1@chromium.org, Nov 21 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/d1c1f2e2b77a2e0f082756f1d908b3ed71712585

commit d1c1f2e2b77a2e0f082756f1d908b3ed71712585
Author: jschuh <jschuh@chromium.org>
Date: Mon Nov 21 21:45:48 2016

Move the remaining CheckedNumeric logic out of the macro

Moves the remaining run-time logic into template classes and functions.
It also eliminates a number of public interfaces used for tests, etc,
and unifies the handling of floating points and integers.

NOTRY=true
BUG= 667097 

Review-Url: https://codereview.chromium.org/2516153002
Cr-Commit-Position: refs/heads/master@{#433659}

[modify] https://crrev.com/d1c1f2e2b77a2e0f082756f1d908b3ed71712585/base/numerics/safe_math.h
[modify] https://crrev.com/d1c1f2e2b77a2e0f082756f1d908b3ed71712585/base/numerics/safe_math_impl.h
[modify] https://crrev.com/d1c1f2e2b77a2e0f082756f1d908b3ed71712585/base/numerics/safe_numerics_unittest.cc

Project Member

Comment 2 by bugdroid1@chromium.org, Nov 24 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/4fcd6fa432b464f64de96c9bb03593b131a07029

commit 4fcd6fa432b464f64de96c9bb03593b131a07029
Author: jschuh <jschuh@chromium.org>
Date: Thu Nov 24 11:58:39 2016

Add variadic helper functions for CheckedNumeric math operations

This introduces variadic template functions that accept two or more
arithmetic or CheckedNumeric arguments and return a CheckedNumeric.
The functions are:

 * base::CheckAdd() - addition
 * base::CheckSub() - subtraction
 * base::CheckMul() - multiplication
 * base::CheckDiv() - division
 * base::CheckMod() - modulous
 * base::CheckLsh() - left integer shift
 * base::CheckRsh() - right integer shift

BUG= 667097 
NOTRY=true
NOPRESUBMIT=true

Review-Url: https://codereview.chromium.org/2522073004
Cr-Commit-Position: refs/heads/master@{#434311}

[modify] https://crrev.com/4fcd6fa432b464f64de96c9bb03593b131a07029/base/numerics/safe_math.h
[modify] https://crrev.com/4fcd6fa432b464f64de96c9bb03593b131a07029/base/numerics/safe_math_impl.h
[modify] https://crrev.com/4fcd6fa432b464f64de96c9bb03593b131a07029/base/numerics/safe_numerics_unittest.cc

Comment 3 by jsc...@chromium.org, Jun 12 2017

Status: Fixed (was: Assigned)

Sign in to add a comment