Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(213)

Issue 6482067: Explicitly cast to uin16_t to avoid an invalid implicit type narrowing. (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 3 months ago by gw280
Modified:
12 years, 3 months ago
Reviewers:
bungeman
CC:
skia-review_googlegroups.com, reed1
Base URL:
https://skia.googlecode.com/svn/trunk
Visibility:
Public.

Description

Explicitly cast to uin16_t to avoid an invalid implicit type narrowing. This was causing a build failure on OS X for us: SkOTTable_head.h:124:72: error: non-type template argument evaluates to -2, which cannot be narrowed to type 'uint16_t' (aka 'unsigned short') [-Wc++11-narrowing] Committed: https://code.google.com/p/skia/source/detail?r=5290

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+2 lines, -2 lines) Patch
M src/sfnt/SkOTTable_head.h View 1 chunk +2 lines, -2 lines 0 comments Download

Messages

Total messages: 5
gw280
12 years, 3 months ago (2012-08-24 18:04:43 UTC) #1
reed1
I'm OK with this change, but I will defer to Ben. Side note: static_cast<SK_OT_SHORT>(SkTEndian_SwapBE16((uint16_t)-1)) That's ...
12 years, 3 months ago (2012-08-27 12:56:36 UTC) #2
bungeman
Since this was the conversion that was implicitly happening before anyway, lgtm. Mike does have ...
12 years, 3 months ago (2012-08-27 14:18:19 UTC) #3
gw280
On 2012/08/27 14:18:19, bungeman wrote: > Since this was the conversion that was implicitly happening ...
12 years, 3 months ago (2012-08-27 15:11:50 UTC) #4
bungeman
12 years, 3 months ago (2012-08-27 15:39:43 UTC) #5
On 2012/08/27 15:11:50, gwright wrote:
> On 2012/08/27 14:18:19, bungeman wrote:
> > Since this was the conversion that was implicitly happening before anyway,
> lgtm.
> > Mike does have a point that SK_OT_SHORT should be uint16_t instead of
int16_t
> > though; I'll make that change later.
> 
> Would it perhaps be more readable to explicitly use 0xFFFF and 0xFFFE instead?

More readable? No, the spec actually says this value is '-1' or '-2';
obfuscating further isn't going to make this clearer. This cast is just to
satisfy a C++11 warning in any event.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b