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 584670 - proper GStaticMutex usage generates warning during compilation
proper GStaticMutex usage generates warning during compilation
Status: RESOLVED DUPLICATE of bug 316221
Product: glib
Classification: Platform
Component: gthread
2.16.x
Other All
: Normal minor
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2009-06-02 22:13 UTC by Jan Spurny
Modified: 2009-06-03 12:55 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Jan Spurny 2009-06-02 22:13:13 UTC
Please describe the problem:
Using GStaticMutex in my code results in gcc warning "dereferencing type-punned pointer will break strict-aliasing rules are generated".


Steps to reproduce:
1. make some program using GStaticMutex
2. compile with gcc -fstrict-aliasing -Wstrict-aliasing



Actual results:
warning: dereferencing type-punned pointer will break strict-aliasing rules

Expected results:
no warning

Does this happen every time?
yes

Other information:
simple example:
-------- ex.c --------------------
#include <glib.h>

int main()
{
	g_thread_init(NULL);
	static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
    	g_static_mutex_lock (&mutex);
    	g_static_mutex_unlock (&mutex);
	return 0;
}
-----------------------------
gcc -Wall -fstrict-aliasing -Wstrict-aliasing `pkg-config --cflags glib-2.0` -o ex ex.c `pkg-config --libs glib-2.0 gthread-2.0`

=>
ex.c: In function 'main':
ex.c:7: warning: dereferencing type-punned pointer will break strict-aliasing rules
ex.c:8: warning: dereferencing type-punned pointer will break strict-aliasing rules


I thing the problem is casting in g_static_mutex_* macros
Comment 1 Dan Winship 2009-06-03 12:55:18 UTC

*** This bug has been marked as a duplicate of 316221 ***