Bug 15114

Summary: Provide compile-time assertions for sizeof(UChar), sizeof(DeprecatedChar), etc.
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: Web Template FrameworkAssignee: Darin Adler <darin>
Status: RESOLVED FIXED    
Severity: Normal CC: ggaren
Priority: P2    
Version: 523.x (Safari 3)   
Hardware: All   
OS: All   
Attachments:
Description Flags
patch ddkilzer: review+

Description David Kilzer (:ddkilzer) 2007-08-29 14:41:07 PDT
* SUMMARY
The UChar and DeprecatedChar structs have implicit assumptions that they are two bytes on all platforms.  It would be nice if there were compile-time assertions that prevented the project from compiling if these assumptions are ever violated.

* NOTES
A Google search yielded some solutions:

Compile Time Assertions in C (CVu 11.3)
http://www.jaggersoft.com/pubs/CVu11_3.html

Compile-Time Assertions & Debugging
http://www.ddj.com/development-tools/184402051

Compile-Time Assertions
http://www.ddj.com/architect/184401873
Comment 1 Geoffrey Garen 2007-08-29 15:56:01 PDT
If this is possible, it would be really helpful to check sizeof all JSObject subclasses at compile time. The collector assumes a maximum size, but it's not checked at compile time.
Comment 2 Darin Adler 2008-02-24 23:03:30 PST
wtf/Assertions.h has COMPILE_ASSERT, so we just need to use it.
Comment 3 Darin Adler 2009-01-04 09:47:20 PST
Created attachment 26413 [details]
patch
Comment 4 David Kilzer (:ddkilzer) 2009-01-04 09:55:28 PST
Comment on attachment 26413 [details]
patch

r=me
Comment 5 Darin Adler 2009-01-04 10:13:17 PST
http://trac.webkit.org/changeset/39585