[Webkit-unassigned] [Bug 54807] New: Always explicitly use "signed" keyword to declare signed bitfields
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Sat Feb 19 07:57:30 PST 2011
https://bugs.webkit.org/show_bug.cgi?id=54807
Summary: Always explicitly use "signed" keyword to declare
signed bitfields
Product: WebKit
Version: 528+ (Nightly build)
Platform: All
OS/Version: All
Status: NEW
Severity: Minor
Priority: P3
Component: WebCore Misc.
AssignedTo: webkit-unassigned at lists.webkit.org
ReportedBy: yong.li.webkit at gmail.com
struct {
int a : 31;
bool b : 1;
};
Many compilers will treat "a" as a signed integer. However, according to standards, making "a" signed or unsigned relies on the implementation of the compiler. We have known armcc treats "a" as unsigned integer. (See Bug 54687). This difference can cause unexpected runtime error. For example:
a = -1;
if (a == -1)
printf("a is signed");
else
printf("a is unsigned"); // -1 will be converted to unsigned number first => 0xFFFFFFFF, and "a" is 0x7FFFFFFF, so they are different.
To make sure our code has same behavior for all compilers and avoid hard-to-locate bugs caused by this, we should always explicitly use "signed" keywords when we want to use signed bitfields (and of course, use "unsigned" keyword in the other case), given that the change will be no-op for most compilers.
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list