|Summary:||statically assert about invariants|
|Product:||dbus||Reporter:||Simon McVittie <smcv>|
|Component:||core||Assignee:||Simon McVittie <smcv>|
|Status:||RESOLVED FIXED||QA Contact:||John (J5) Palmieri <johnp>|
|i915 platform:||i915 features:|
|Bug Depends on:|
[PATCH 1/2] Add _DBUS_STATIC_ASSERT (based on GLib's G_STATIC_ASSERT) and use it
[PATCH 2/2] dbus-marshal-basic: assert that the size and (on gcc) alignment of all types is as expected
Description Simon McVittie 2011-07-28 09:52:03 UTC
Various libraries use "static assertions" to check invariants at compile-time, with no runtime overhead. For instance, it's easy to check that things have the expected sizeof(). Under gcc 4, __alignof__() is also easy to check.
Comment 1 Simon McVittie 2011-07-28 09:54:02 UTC
Created attachment 49677 [details] [review] [PATCH 1/2] Add _DBUS_STATIC_ASSERT (based on GLib's G_STATIC_ASSERT) and use it
Comment 2 Simon McVittie 2011-07-28 09:55:44 UTC
Created attachment 49678 [details] [review] [PATCH 2/2] dbus-marshal-basic: assert that the size and (on gcc) alignment of all types is as expected The __alignof__() checks here will fail if compiling for an architecture where more-than-natural alignment is needed. --- Possibly those architectures can't exist, or can't implement ISO C; I don't really care. If they exist, the checks will make D-Bus fail to compile there (where previously it failed at runtime), and if they don't, the checks have no effect at runtime anyway.
Comment 4 Will Thompson 2011-08-05 05:06:16 UTC
Review of attachment 49678 [details] [review]: Looks fine!
Comment 5 Simon McVittie 2011-08-11 04:00:01 UTC
Thanks, fixed in 1.4.16, 1.5.8