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 373910 - Add G_GNUC_MAY_ALIAS
Add G_GNUC_MAY_ALIAS
Status: RESOLVED DUPLICATE of bug 335853
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2006-11-11 16:32 UTC by Marco Barisione
Modified: 2006-11-13 06:01 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Marco Barisione 2006-11-11 16:32:20 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.
Comment 1 Behdad Esfahbod 2006-11-13 06:01:37 UTC

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