[Webkit-unassigned] [Bug 143457] New: Fix -Wparentheses warning with GCC 5 in SaturatedArithmetic.h
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Mon Apr 6 15:53:44 PDT 2015
https://bugs.webkit.org/show_bug.cgi?id=143457
Bug ID: 143457
Summary: Fix -Wparentheses warning with GCC 5 in
SaturatedArithmetic.h
Classification: Unclassified
Product: WebKit
Version: 528+ (Nightly build)
Hardware: PC
OS: Linux
Status: NEW
Severity: Minor
Priority: P2
Component: Web Template Framework
Assignee: webkit-unassigned at lists.webkit.org
Reporter: mcatanzaro at igalia.com
When building with GCC 5, I can't see any real warnings, because this buddy gets printed 3000 times [1] during compilation:
../../Source/WTF/wtf/SaturatedArithmetic.h: In function âbool signedAddOverflows(int32_t, int32_t, int32_t&)â:
../../Source/WTF/wtf/SaturatedArithmetic.h:49:29: warning: suggest parentheses around operand of â!â or change â&â to â&&â or â!â to â~â [-Wparentheses]
return !((ua ^ ub) >> 31) & (uresult ^ ua) >> 31;
^
Clang has had this same warning for a while. The warning is spurious [2], but it's a good warning so let's placate it rather than disable. Two solutions:
Add extra parentheses: return (!((ua ^ ub) >> 31)) & (uresult ^ ua) >> 31;
Note that is equivalent to the original code [3].
Another option is to use &&:
!((ua ^ ub) >> 31) && (uresult ^ ua) >> 31;
That looks better to me, since there are fewer parentheses and it avoids the confusing/unnecessary [3] mask.
[1] I just made that up, but it doesn't feel like an unreasonable guess.
[2] & and && both have the same precedence relative to !
[3] Provided I've squinted at this long enough.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20150406/1115db24/attachment.html>
More information about the webkit-unassigned
mailing list