[Webkit-unassigned] [Bug 55088] New: To COMPILE_ASSERT bitfields are packed with expected size

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Feb 23 15:00:31 PST 2011


https://bugs.webkit.org/show_bug.cgi?id=55088

           Summary: To COMPILE_ASSERT bitfields are packed with expected
                    size
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P4
         Component: WebKit Misc.
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: yong.li.webkit at gmail.com


How bitfields are packed relies on compiler implementation. For example:

struct {
int x : 31;
bool y : 1;
};

Above struct consumes 8 bytes in MSVC, where we probably expect it uses only 4 bytes (otherwise why do we even use bitfields?). Unfortunately, we are widely using this pattern in webkit.

More information:

http://msdn.microsoft.com/en-us/library/hx1b6kkd.aspx

"Adjacent bit fields are packed into the same 1-, 2-, or 4-byte allocation unit if the integral types are the same size and if the next bit field fits into the current allocation unit without crossing the boundary imposed by the common alignment requirements of the bit fields. "

Ideally, we should be able to assert bitfields are packed with expected size at compile time. Also it would be nice if check-webkit-style can detect such issues.

-- 
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