Bug 137471 - [Win] Use of 1-bit Enum type behaves improperly
Summary: [Win] Use of 1-bit Enum type behaves improperly
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Brent Fulgham
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2014-10-06 17:22 PDT by Brent Fulgham
Modified: 2014-10-06 20:11 PDT (History)
3 users (show)

See Also:


Attachments
Patch (1.65 KB, patch)
2014-10-06 17:27 PDT, Brent Fulgham
mark.lam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brent Fulgham 2014-10-06 17:22:31 PDT
MSVC implements enumerated types as signed values. This causes problems when enums are used as elements in a bit field (especially 1-bit elements) because MSVC wants to include a sign bit in its encoding. This means we lose one bit of resolution, often causing incorrect behavior.

Static analysis found this problem in Debugger.h.

This patch corrects the bug so that we don't run into this on Windows builds.
Comment 1 Radar WebKit Bug Importer 2014-10-06 17:23:12 PDT
<rdar://problem/18563519>
Comment 2 Brent Fulgham 2014-10-06 17:23:25 PDT
See also Bug 134252.
Comment 3 Brent Fulgham 2014-10-06 17:27:24 PDT
Created attachment 239369 [details]
Patch
Comment 4 Mark Lam 2014-10-06 18:18:24 PDT
Comment on attachment 239369 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=239369&action=review

r=me with the comment added.

> Source/JavaScriptCore/debugger/Debugger.h:195
> +    unsigned m_steppingMode : 1;

I recall Darin saying that the accepted practice is to add a trailing comment to indicate the expected type:

unsigned m_steppingMode : 1; // SteppingMode
Comment 5 Brent Fulgham 2014-10-06 20:10:37 PDT
Comment on attachment 239369 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=239369&action=review

>> Source/JavaScriptCore/debugger/Debugger.h:195
>> +    unsigned m_steppingMode : 1;
> 
> I recall Darin saying that the accepted practice is to add a trailing comment to indicate the expected type:
> 
> unsigned m_steppingMode : 1; // SteppingMode

Will do!
Comment 6 Brent Fulgham 2014-10-06 20:11:38 PDT
Committed in r174381. <http://trac.webkit.org/changeset/174381>