Bug 95293 - [chromium] Use floating point literals in expressions that initialize floats
Summary: [chromium] Use floating point literals in expressions that initialize floats
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: James Robinson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-28 23:30 PDT by James Robinson
Modified: 2012-08-29 09:21 PDT (History)
6 users (show)

See Also:


Attachments
Patch (2.97 KB, patch)
2012-08-28 23:32 PDT, James Robinson
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description James Robinson 2012-08-28 23:30:20 PDT
[chromium] Use floating point literals in expressions that initialize floats
Comment 1 James Robinson 2012-08-28 23:32:49 PDT
Created attachment 161144 [details]
Patch
Comment 2 Adam Barth 2012-08-28 23:54:06 PDT
Comment on attachment 161144 [details]
Patch

This is technically against WebKit style, but given that this code is going to GTFO, this seems fine.
Comment 3 WebKit Review Bot 2012-08-29 01:42:36 PDT
Comment on attachment 161144 [details]
Patch

Attachment 161144 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/13690106

New failing tests:
CCLayerTreeHostTestAtomicCommitWithPartialUpdate.runMultiThread
Comment 4 WebKit Review Bot 2012-08-29 03:51:53 PDT
Comment on attachment 161144 [details]
Patch

Clearing flags on attachment: 161144

Committed r126981: <http://trac.webkit.org/changeset/126981>
Comment 5 WebKit Review Bot 2012-08-29 03:51:56 PDT
All reviewed patches have been landed.  Closing bug.
Comment 6 Dana Jansens 2012-08-29 07:51:17 PDT
For those of us not building with VS, should we always be using f suffix? It surprises me that these are the only double literal->float truncations in our code base, are these somehow special?
Comment 7 Adam Barth 2012-08-29 08:24:00 PDT
> For those of us not building with VS, should we always be using f suffix?

Nope.

> It surprises me that these are the only double literal->float truncations in our code base, are these somehow special?

They're special because we're in the process of moving this code out of WebKit to a location where more warnings are enabled.
Comment 8 Dana Jansens 2012-08-29 08:27:41 PDT
(In reply to comment #7)
> > For those of us not building with VS, should we always be using f suffix?
> 
> Nope.
> 
> > It surprises me that these are the only double literal->float truncations in our code base, are these somehow special?
> 
> They're special because we're in the process of moving this code out of WebKit to a location where more warnings are enabled.

Right, I am wondering about future compositor code, not WebKit :) For example we have tons of things like FloatPoint(0.5, 0) in our tests. These are using a double literal for a float as well, but are not causing compiler warnings?
Comment 9 James Robinson 2012-08-29 09:21:47 PDT
The WebKit style is "use f if you need to force floating-point math".  In this instances, we need to force floating point math or MSVS warns (somewhat correctly) that the narrowing conversion is lossly.

Initializing to 0.5, 0 probably doesn't need anything since 0.5 and 0 are exactly representable as doubles and floats, so it's not lossy.  I'm guessing that since 0.1, 0.01, and 0.95 do not have exact representations as doubles or floats, and the float representation is not equivalent to the double representation, the compiler is less happy.