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 691107 - G_STATIC_ASSERT fails to build on gcc 4.8 due to -Wunused-local-typedefs
G_STATIC_ASSERT fails to build on gcc 4.8 due to -Wunused-local-typedefs
Status: RESOLVED DUPLICATE of bug 686773
Product: glib
Classification: Platform
Component: build
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-01-04 03:37 UTC by Sam Spilsbury
Modified: 2013-04-06 15:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix "unused local typedef" warning in G_STATIC_ASSERT (904 bytes, patch)
2013-04-06 15:27 UTC, John Lindgren
none Details | Review

Description Sam Spilsbury 2013-01-04 03:37:46 UTC
G_STATIC_ASSERT uses a typedef _GStaticAssertCompileTimeAssertion_1 which is later unused, and fails to build with -Werror on gcc 4.8:

/usr/include/glib-2.0/glib/gmacros.h:162:53: warning: typedef ‘_GStaticAssertCompileTimeAssertion_0’ locally defined but not used [-Wunused-local-typedefs]
 #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1]
                                                     ^
/usr/include/glib-2.0/glib/gmacros.h:159:47: note: in definition of macro ‘G_PASTE_ARGS’
 #define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
                                               ^
/usr/include/glib-2.0/glib/gmacros.h:162:44: note: in expansion of macro ‘G_PASTE’
 #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1]
                                            ^
/usr/include/glib-2.0/glib/gthread.h:234:5: note: in expansion of macro ‘G_STATIC_ASSERT’
     G_STATIC_ASSERT (sizeof *(location) == sizeof (gpointer));       \
     ^
/usr/include/glib-2.0/gobject/gtype.h:1463:7: note: in expansion of macro ‘g_once_init_enter’
   if (g_once_init_enter (&g_define_type_id__volatile))  \
       ^
/usr/include/glib-2.0/gobject/gtype.h:1294:56: note: in expansion of macro ‘_G_DEFINE_TYPE_EXTENDED_BEGIN’
 #define G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_)     _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
                                                        ^
/home/mcr2010/src/bzr/compiz/gtk/window-decorator/gwd-settings-notified.c:51:1: note: in expansion of macro ‘G_DEFINE_TYPE_WITH_CODE’
 G_DEFINE_TYPE_WITH_CODE (GWDSettingsNotifiedImpl, gwd_settings_notified_impl, G_TYPE_OBJECT,
 ^
/usr/include/glib-2.0/glib/gmacros.h:162:53: warning: typedef ‘_GStaticAssertCompileTimeAssertion_1’ locally defined but not used [-Wunused-local-typedefs]
 #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1]
                                                     ^
/usr/include/glib-2.0/glib/gmacros.h:159:47: note: in definition of macro ‘G_PASTE_ARGS’
 #define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
                                               ^
/usr/include/glib-2.0/glib/gmacros.h:162:44: note: in expansion of macro ‘G_PASTE’
 #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1]
                                            ^
/usr/include/glib-2.0/glib/gatomic.h:136:5: note: in expansion of macro ‘G_STATIC_ASSERT’
     G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer));                 \
     ^
/usr/include/glib-2.0/glib/gthread.h:236:7: note: in expansion of macro ‘g_atomic_pointer_get’
     (!g_atomic_pointer_get (location) &&                             \
       ^
/usr/include/glib-2.0/gobject/gtype.h:1463:7: note: in expansion of macro ‘g_once_init_enter’
   if (g_once_init_enter (&g_define_type_id__volatile))  \
       ^
/usr/include/glib-2.0/gobject/gtype.h:1294:56: note: in expansion of macro ‘_G_DEFINE_TYPE_EXTENDED_BEGIN’
 #define G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_)     _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
                                                        ^
/home/mcr2010/src/bzr/compiz/gtk/window-decorator/gwd-settings-notified.c:51:1: note: in expansion of macro ‘G_DEFINE_TYPE_WITH_CODE’
 G_DEFINE_TYPE_WITH_CODE (GWDSettingsNotifiedImpl, gwd_settings_notified_impl, G_TYPE_OBJECT,
 ^
/usr/include/glib-2.0/glib/gmacros.h:162:53: warning: typedef ‘_GStaticAssertCompileTimeAssertion_2’ locally defined but not used [-Wunused-local-typedefs]
 #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1]
                                                     ^
/usr/include/glib-2.0/glib/gmacros.h:159:47: note: in definition of macro ‘G_PASTE_ARGS’
 #define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
                                               ^
/usr/include/glib-2.0/glib/gmacros.h:162:44: note: in expansion of macro ‘G_PASTE’
 #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1]
                                            ^
/usr/include/glib-2.0/glib/gthread.h:241:5: note: in expansion of macro ‘G_STATIC_ASSERT’
     G_STATIC_ASSERT (sizeof *(location) == sizeof (gpointer));       \
     ^
/usr/include/glib-2.0/gobject/gtype.h:1477:7: note: in expansion of macro ‘g_once_init_leave’
       g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); \
       ^
/usr/include/glib-2.0/gobject/gtype.h:1294:111: note: in expansion of macro ‘_G_DEFINE_TYPE_EXTENDED_END’
 #define G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_)     _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
                                                                                                               ^
/home/mcr2010/src/bzr/compiz/gtk/window-decorator/gwd-settings-notified.c:51:1: note: in expansion of macro ‘G_DEFINE_TYPE_WITH_CODE’
 G_DEFINE_TYPE_WITH_CODE (GWDSettingsNotifiedImpl, gwd_settings_notified_impl, G_TYPE_OBJECT,
 ^
Comment 1 Allison Karlitskaya (desrt) 2013-01-04 04:14:17 UTC
I pity the fool who uses -Werror

Seriously, though.  See bug 686773 for the most plausible way out of this mess...

*** This bug has been marked as a duplicate of bug 686773 ***
Comment 2 Sam Spilsbury 2013-01-04 04:15:12 UTC
Ah, I thought there might have been a dupe, but searching for gcc 4.8 didn't show it. Cheers.
Comment 3 John Lindgren 2013-04-06 15:27:00 UTC
Created attachment 240843 [details] [review]
Fix "unused local typedef" warning in G_STATIC_ASSERT

I don't see why we need _Static_assert to solve this.  Is there a problem with just adding G_GNUC_UNUSED to the typedef?

Please reopen.