Closed
Bug 454856
Opened 16 years ago
Closed 16 years ago
gcc seems to miscompile some fp math, leading to off-by-1 errors in colors
Categories
(Core :: Graphics, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: vlad, Assigned: vlad)
Details
Attachments
(2 files)
371 bytes,
text/plain
|
Details | |
2.78 KB,
patch
|
bholley
:
review+
|
Details | Diff | Splinter Review |
In gfxColor.h, the Packed() function did things like: (double r,g,b,a; are part of the struct) (((PRUint8)(a * 255.0) << 24) | ((PRUint8)(b * 255.0) << 16) | ((PRUint8)(g * 255.0) << 8) | ((PRUint8)(r * 255.0))); At least gcc 4.2.3 on Ubuntu 8.04 is doing something weird there, because the results differ from when optimization is turned on or off. The attached simple C testcase demonstrates the problem. If an intermediate double variable is used to hold the result of a * 255.0, and the cast to PRUint8 is done as a separate step, the right value seems to result. If -Os or -O2 is used, the right value appears in both cases. gcc on MacOS X, both 4.0.1 and 4.2.1, end up with the right result.
Assignee | ||
Comment 1•16 years ago
|
||
Fix gfxColor::Packed to use a pattern where gcc does what we want in both debug and opt builds. There's likely to be something more robust that can be done here, but I'm not sure what.
Assignee: nobody → vladimir
Attachment #338172 -
Flags: review?(bholley)
Updated•16 years ago
|
Attachment #338172 -
Flags: review?(bholley) → review+
Comment 2•16 years ago
|
||
Comment on attachment 338172 [details] [diff] [review] fix gfxColor::Packed looks good - how is this tree closure going to affect landing?
Assignee | ||
Comment 3•16 years ago
|
||
Checked in.
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•