Bug 15114 - Provide compile-time assertions for sizeof(UChar), sizeof(DeprecatedChar), etc.
Summary: Provide compile-time assertions for sizeof(UChar), sizeof(DeprecatedChar), etc.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: 523.x (Safari 3)
Hardware: All All
: P2 Normal
Assignee: Darin Adler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-08-29 14:41 PDT by David Kilzer (:ddkilzer)
Modified: 2009-01-04 10:13 PST (History)
1 user (show)

See Also:


Attachments
patch (1.15 KB, patch)
2009-01-04 09:47 PST, Darin Adler
ddkilzer: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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