GNOME Bugzilla – Bug 373910
Add G_GNUC_MAY_ALIAS
Last modified: 2006-11-13 06:01:37 UTC
I have this code: typedef struct { gint dummy; } S; S *sp = g_new0 (S, 1); S *new_val = g_new0 (S, 1); g_atomic_pointer_compare_and_exchange ((gpointer *)&sp, NULL, new_val); gcc gives this warning: warning: dereferencing type-punned pointer will break strict-aliasing rules The solutions in this case could be: - Use a dummy union - Disable strict aliasing - Use __attribute__((__may_alias__)) - Ignore the warning I think that the only acceptable solution is to use the attribute, so I propose to add a G_GNUC_MAY_ALIAS macro for GCC. This was already discussed in bug #335341 and in the mailing list: http://mail.gnome.org/archives/gtk-devel-list/2005-February/msg00001.html If you think that G_GNUC_MAY_ALIAS is ok I can write the patch for gmacros.h and for the documentation.
*** This bug has been marked as a duplicate of 335853 ***