GNOME Bugzilla – Bug 507134
G_LOCK() and G_UNLOCK() might break strict-aliasing rules
Last modified: 2008-02-08 00:06:34 UTC
Hi, when compiling the code below with gcc 4.3 (trunk revision 131293) with -fstrict-aliasing and -Wall -Werror one gets the following compiler output: gcc-4.3 -o tset test.c -Wall `pkg-config --libs --cflags glib-2.0` -Werror -fstrict-aliasing -O0 cc1: warnings being treated as errors test.c: In function ‘main’: test.c:7: error: dereferencing type-punned pointer will break strict-aliasing rules test.c:8: error: dereferencing type-punned pointer will break strict-aliasing rules Is this a GLib bug or a gcc one? gcc 4.2 and below didn't complain so either gcc became more correct or more buggy ;) This is with glib 2.15.0... test code: #include <glib.h> G_LOCK_DEFINE_STATIC (test_lock); int main() { G_LOCK (test_lock); G_UNLOCK (test_lock); return 0; }
*** This bug has been marked as a duplicate of 316221 ***