New issue
Advanced search Search tips

Issue 754884 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Aug 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Feature



Sign in to add a comment

checked_cast should support enum sources

Project Member Reported by jyasskin@chromium.org, Aug 11 2017

Issue description

https://chromium-review.googlesource.com/c/602866/1..2/base/cbor/cbor_writer.cc#75 says that a checked_cast<uint8_t>(some_enum) fails to compile with 'no matching function for call to "IsValueInRangeForNumericTypes" '. You should be able to use http://en.cppreference.com/w/cpp/types/underlying_type to map enums to their integer representation type.
 
Cc: kpaulhamus@chromium.org
Sorry for not reading before making suggestions. Kim, can you paste the exact error message here?

Comment 3 by jsc...@chromium.org, Aug 14 2017

I wrote a small test and it turns out that the implementation needs some more explicit casts.

I'll have a small CL up for review today.
Project Member

Comment 4 by bugdroid1@chromium.org, Aug 14 2017

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

commit 4d93ee3a4e6940994e72a60ee924db9c94633b8d
Author: Justin Schuh <jschuh@chromium.org>
Date: Mon Aug 14 20:06:28 2017

Support enum in base/numerics cast templates

This fixes checked_cast<>, saturated_cast<>, and strict_cast<> so they
properly support enum source types.

Bug:  754884 
Change-Id: I759fb42d08447c99cc19bd1b913956539d37d706
Reviewed-on: https://chromium-review.googlesource.com/613685
Commit-Queue: Justin Schuh <jschuh@chromium.org>
Commit-Queue: Jeffrey Yasskin <jyasskin@chromium.org>
Reviewed-by: Jeffrey Yasskin <jyasskin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#494153}
[modify] https://crrev.com/4d93ee3a4e6940994e72a60ee924db9c94633b8d/base/numerics/safe_conversions.h
[modify] https://crrev.com/4d93ee3a4e6940994e72a60ee924db9c94633b8d/base/safe_numerics_unittest.cc

Comment 5 by jsc...@chromium.org, Aug 15 2017

Owner: jsc...@chromium.org
Status: Fixed (was: Untriaged)

Sign in to add a comment