Fix a bunch of undefined behavior in CheckedNumericState

CheckedNumericState<T, NUMERIC_INTEGER> would unconditionally cast
the src type to the dest int type.  If the source type was a floating
point type that didn't fit in the integer type, this was undefined
behavior.

So only cast if is_valid_ is true.  To be able to check that, move
is_valid_ in front of the value_ field (since these are constexpr
ctors and we don't have C++14 constexpr).

BUG=669642

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


CrOS-Libchrome-Original-Commit: e5b63cc2f7896b3ed1e8d89c3cab0b077ac14cc9
1 file changed
tree: 1ab825c5ca7226688529d09f1f0b76ecde7858c3
  1. base/
  2. build/
  3. components/
  4. dbus/
  5. device/
  6. ipc/
  7. mojo/
  8. testing/
  9. third_party/
  10. ui/