g_atomic_pointer_get and -Werror=bad-function-cast causes build error
Submitted by Stefan Windfeldt
Link to original bug (#749819)
Description
When calling g_atomic_pointer_get with a gsize (as is called for example when declaring a GObject) you get a build error if you have declared -Werror=bad-function-cast.
I got this error when declaring a GObject but can reproduce it with a program like this: #include <glib/gprintf.h>
int main() {
gsize *s = 0;
g_atomic_pointer_get (&s);
return 0;
}
And when compiled with these flags:
gcc hello.c -Werror=bad-function-cast pkg-config --cflags --libs glib-2.0
-o hello
It leads to this error:
hello.c: In function ‘main’:
/usr/include/glib-2.0/glib/gatomic.h:108:5: error: cast from function call of type ‘long unsigned int’ to non-matching type ‘void *’ [-Werror=bad-function-cast]
(gpointer) __atomic_load_8 ((atomic), __ATOMIC_SEQ_CST); \
^
hello.c:6:3: note: in expansion of macro ‘g_atomic_pointer_get’
g_atomic_pointer_get (&s);
^
cc1: some warnings being treated as errors
The problem seems to have been introduced with this commit: https://git.gnome.org/browse/glib/commit/glib/gatomic.h?id=db0e43d25a5316f3a6f2f31712a0b8359e247a20
Version: 2.42.x