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 692583 - atomic get doesn't accept a const argument on architectures where it isn't lock-free
atomic get doesn't accept a const argument on architectures where it isn't lo...
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-01-26 16:42 UTC by Simon McVittie
Modified: 2013-01-28 11:52 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
g_atomic_int_get, g_atomic_pointer_get: accept const arguments (3.70 KB, patch)
2013-01-26 17:40 UTC, Simon McVittie
accepted-commit_now Details | Review

Description Simon McVittie 2013-01-26 16:42:02 UTC
The macro implementation of g_atomic_pointer_get() will happily dereference a "const volatile void *", with no warnings or errors. However, the function implementation takes a "volatile void *", so it's invalid (normally a warning in C or an error in C++) to pass the same pointer to it.

This can result in code that doesn't specifically rely on lock-free operations, compiles perfectly well on platforms that have lock-free operations, but doesn't compile on platforms that don't; in particular, sigx didn't compile on Debian armel, which is armv4t. <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=699021>

As far as I can see, g_atomic_int_get() has the same issue.
Comment 1 Simon McVittie 2013-01-26 17:40:00 UTC
Created attachment 234483 [details] [review]
g_atomic_int_get, g_atomic_pointer_get: accept const  arguments

---

... and a regression test for the same. Tested on Linux, also compiled-but-not-tested for i686-w64-mingw32 (32-bit Windows).
Comment 2 Matthias Clasen 2013-01-26 21:09:27 UTC
Review of attachment 234483 [details] [review]:

Thanks, looks good
Comment 3 Simon McVittie 2013-01-28 11:52:54 UTC
Thanks, fixed in git for 2.35.5, commit cf68300d27784ab5baaf6ef4761cead0ec404b1f.