After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 626549 - G_STATIC_ASSERT_EXPR
G_STATIC_ASSERT_EXPR
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
: G_STATIC_ASSERT_EXPR (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2010-08-10 16:55 UTC by Behdad Esfahbod
Modified: 2011-05-28 02:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add G_STATIC_ASSERT_EXPR macro (2.12 KB, patch)
2011-05-22 16:54 UTC, Allison Karlitskaya (desrt)
committed Details | Review
Add G_STATIC_ASSERT_EXPR macro (2.12 KB, patch)
2011-05-28 02:37 UTC, Matthias Clasen
committed Details | Review

Description Behdad Esfahbod 2010-08-10 16:55:16 UTC
In gatomic.h one finds many lines of code like this:

# define g_atomic_pointer_get(atomic) \ 
 ((void) sizeof (gchar [sizeof (*(atomic)) == sizeof (gpointer) ? 1 : -1]), \ 
  (g_atomic_pointer_get) ((volatile gpointer G_GNUC_MAY_ALIAS *) (volatile void *) (atomic))) 

Lets add G_STATIC_ASSERT_EXPR() to hide the verbose assertion expression.
Comment 1 Matthias Clasen 2011-05-22 03:04:34 UTC
*** Bug 648426 has been marked as a duplicate of this bug. ***
Comment 2 Matthias Clasen 2011-05-22 05:05:42 UTC
Something like 

#define G_STATIC_ASSERT_EXPR(expr) ((void) sizeof (char[(expr) ? 1 : -1]))

?
Comment 3 Allison Karlitskaya (desrt) 2011-05-22 16:54:07 UTC
Created attachment 188342 [details] [review]
Add G_STATIC_ASSERT_EXPR macro
Comment 4 Matthias Clasen 2011-05-22 20:08:49 UTC
Review of attachment 188342 [details] [review]:

Looks good to me.

Will you also do the companion patch to use G_STATIC_ASSERT_EXPR in gatomic.h ?
Comment 5 Matthias Clasen 2011-05-22 20:09:05 UTC
Review of attachment 188342 [details] [review]:

set patch status
Comment 6 Matthias Clasen 2011-05-28 02:37:48 UTC
The following fix has been pushed:
c00ef0a Add G_STATIC_ASSERT_EXPR macro
Comment 7 Matthias Clasen 2011-05-28 02:37:54 UTC
Created attachment 188796 [details] [review]
Add G_STATIC_ASSERT_EXPR macro