Bug 137471

Summary: [Win] Use of 1-bit Enum type behaves improperly
Product: WebKit Reporter: Brent Fulgham <bfulgham>
Component: JavaScriptCoreAssignee: Brent Fulgham <bfulgham>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, mark.lam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch mark.lam: review+

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>