RESOLVED FIXED Bug 113308
Support C++11 static_assert
https://bugs.webkit.org/show_bug.cgi?id=113308
Summary Support C++11 static_assert
Allan Sandfeld Jensen
Reported 2013-03-26 07:20:28 PDT
When available we use the Clang extension _Static_assert for compile assertion since this is just a C version of the C++11 static assert we should use the C++11 version when possible. Note this is not always possible since Assertions.h where COMPILE_ASSERT is defined can be used from both C and C++, and COMPILE_ASSERT will therefore still not be available in C for non clang compilers.
Attachments
Patch (1.97 KB, patch)
2013-03-26 07:24 PDT, Allan Sandfeld Jensen
no flags
Patch (3.83 KB, patch)
2013-03-27 03:55 PDT, Allan Sandfeld Jensen
no flags
Patch (2.98 KB, patch)
2013-03-27 03:57 PDT, Allan Sandfeld Jensen
no flags
Allan Sandfeld Jensen
Comment 1 2013-03-26 07:24:03 PDT
Alexey Proskuryakov
Comment 2 2013-03-26 11:01:43 PDT
Comment on attachment 195083 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=195083&action=review > Source/WTF/wtf/Assertions.h:348 > #if COMPILER_SUPPORTS(C_STATIC_ASSERT) > #define COMPILE_ASSERT(exp, name) _Static_assert((exp), #name) I think that this should have a comment explaining why we still have this: // Unlike static_assert below, this also works in plain C code. That said, I'm unsure if we ever use - or want to use - COMPILE_ASSERT in plain C code. > Source/WTF/wtf/Compiler.h:128 > +#define WTF_COMPILER_SUPPORTS_CXX_STATIC_ASSERT 1 Shouldn't this be defined for clang too? The behavior in this patch would not be affected, but it's better to not leave such a tripmine for later IMO.
Allan Sandfeld Jensen
Comment 3 2013-03-27 03:55:01 PDT
Created attachment 195266 [details] Patch Added detection of C++11 static_assert to clang, and C11 _Static_assert to GCC.
Allan Sandfeld Jensen
Comment 4 2013-03-27 03:57:06 PDT
Created attachment 195267 [details] Patch Remove accidentially uploaded change.
Allan Sandfeld Jensen
Comment 5 2013-03-27 10:31:03 PDT
Comment on attachment 195267 [details] Patch Clearing flags on attachment: 195267 Committed r146993: <http://trac.webkit.org/changeset/146993>
Allan Sandfeld Jensen
Comment 6 2013-03-27 10:31:07 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.