GNOME Bugzilla – Bug 772743
macros: generate uniq variable name in _G_BOOLEAN_EXPR()/G_LIKELY()
Last modified: 2018-05-24 19:09:26 UTC
This avoids a -Wshadow warning when nesting G_LIKELY() inside each other due to _g_boolean_var_. This can be easily encountered when using macros: #define GET_VALUE(arg) \ ({ \ typeof (arg) _arg = (arg); \ \ g_assert (_arg); \ get_value (_arg); \ }) g_assert (GET_VALUE (a) > 5); __COUNTER__ is a GCC extension, but the definition of _G_BOOLEAN_EXPR() is already inside a #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) block.
Created attachment 337400 [details] [review] macros: generate uniq variable name in _G_BOOLEAN_EXPR()/G_LIKELY()
or maybe just drop _G_BOOLEAN_EXPR entirely. See: https://bugzilla.gnome.org/show_bug.cgi?id=760215#c6
Review of attachment 337400 [details] [review]: ::: glib/gmacros.h @@ +370,2 @@ if (expr) \ + G_PASTE (_g_boolean_var_, uniq) = 1; \ Couldn't we just use: expr ? 1 : 0 ?
I guess, originally it was implemented that way because * The _G_BOOLEAN_EXPR macro is intended to trigger a gcc warning when * putting assignments in g_return_if_fail (). But I don't think that works anymore. See https://bugzilla.gnome.org/show_bug.cgi?id=760215#c6 . Which makes _G_BOOLEAN_EXPR() in this form pointless.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/1211.