GNOME Bugzilla – Bug 457641
glib-2.13.7: C++ conversion problem in gthread.h
Last modified: 2010-04-15 17:08:02 UTC
A C++ conversion from in gthread.h prevents poppler-0.5.9 from building. See below. -Joseph ===================================================== /usr/local/src/GARNOME/Devel/garnome-trunk/include/glib-2.0/glib/gthread.h:335: error: cannot convert 'volatile gsize*' to 'void* volatile*' for argument '1' to 'void* g_atomic_pointer_get(void* volatile*)' make[2]: *** [poppler-action.lo] Error 1 make[2]: Leaving directory `/usr/local/src/GARNOME/Devel/garnome-trunk/src/freedesktop/poppler/work/main.d/poppler-0.5.9/glib'
Same with gtk, it does not build on Linux/Sparc (gcc 3.4.6): Making all in tests if g++ -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I../gdk -I../gdk -DGDK_PIXBUF_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DG_DISABLE_CAST_CHECKS -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/atk-1.0 -I/usr/X11R6/include -I./dummy-headers -I/usr/X11R6/include -I/usr/X11R6//include -O2 -pipe -MT autotestkeywords-autotestkeywords.o -MD -MP -MF ".deps/autotestkeywords-autotestkeywords.Tpo" \ -c -o autotestkeywords-autotestkeywords.o `test -f 'autotestkeywords.cc' || echo './'`autotestkeywords.cc; \ then mv -f ".deps/autotestkeywords-autotestkeywords.Tpo" ".deps/autotestkeywords-autotestkeywords.Po"; \ else rm -f ".deps/autotestkeywords-autotestkeywords.Tpo"; exit 1; \ fi In file included from /usr/include/glib-2.0/glib/gasyncqueue.h:30, from /usr/include/glib-2.0/glib.h:32, from ../gdk/gdktypes.h:32, from ../gdk/gdkcolor.h:31, from ../gdk/gdkcairo.h:23, from ../gdk/gdk.h:30, from ../gtk/gtk.h:31, from autotestkeywords.cc:1: /usr/include/glib-2.0/glib/gthread.h: In function `gboolean g_once_init_enter(volatile gsize*)': /usr/include/glib-2.0/glib/gthread.h:335: error: cannot convert `volatile gsize*' to `void* volatile*' for argument `1' to `void* g_atomic_pointer_get(void* volatile*)' make[4]: *** [autotestkeywords-autotestkeywords.o] Error 1
*** Bug 458025 has been marked as a duplicate of this bug. ***
*** Bug 459077 has been marked as a duplicate of this bug. ***
I'm bumping the severity to blocker as it prevents other apps from building on these arches (such as gtk).
That has already been fixed to SVN for some time, http://svn.gnome.org/viewcvs/glib?view=revision&revision=5637
The problem still exists on x86. I'm using Gentoo with GCC 4.2.0 with GLib 2.14.0 and when trying to build Wireshark I receive the following error message : cc1: warnings being treated as errors In file included from /usr/include/glib-2.0/glib/gasyncqueue.h:30, from /usr/include/glib-2.0/glib.h:32, from wtap-int.h:30, from ascend.c:26: /usr/include/glib-2.0/glib/gthread.h: In function 'g_once_init_enter': /usr/include/glib-2.0/glib/gthread.h:335: warning: cast discards qualifiers from pointer target type make[3]: *** [libwiretap_la-ascend.lo] Error 1
(In reply to comment #6) > The problem still exists on x86. > > I'm using Gentoo with GCC 4.2.0 with GLib 2.14.0 and when trying to build > Wireshark I receive the following error message : > > cc1: warnings being treated as errors > In file included from /usr/include/glib-2.0/glib/gasyncqueue.h:30, > from /usr/include/glib-2.0/glib.h:32, > from wtap-int.h:30, > from ascend.c:26: > /usr/include/glib-2.0/glib/gthread.h: In function 'g_once_init_enter': > /usr/include/glib-2.0/glib/gthread.h:335: warning: cast discards qualifiers > from pointer target type > make[3]: *** [libwiretap_la-ascend.lo] Error 1 >
(In reply to comment #6) > The problem still exists on x86. > /usr/include/glib-2.0/glib/gthread.h: In function 'g_once_init_enter': > /usr/include/glib-2.0/glib/gthread.h:335: warning: cast discards qualifiers > from pointer target type can you please confirm that the following patch fixes the error for you? Index: glib/gthread.h =================================================================== diff -Nup glib/.svn/text-base/gthread.h.svn-base /tmp/svndiff.tmp --- glib/gthread.h (revision 5713) +++ glib/gthread.h (working copy) @@ -332,7 +332,7 @@ void g_once_init_leav G_INLINE_FUNC gboolean g_once_init_enter (volatile gsize *value_location) { - if G_LIKELY (g_atomic_pointer_get ((void**) value_location) != 0) + if G_LIKELY (g_atomic_pointer_get ((void*volatile*) value_location) != 0) return FALSE; else return g_once_init_enter_impl (value_location);
(In reply to comment #8) This does indeed fix compiling wireshark from svn for me.
Wed Aug 29 12:08:40 2007 Tim Janik <timj@imendio.com> * glib/gthread.h (g_once_init_enter): fixed compiler warning about loosing volatile qualifier, bug #457641.
Created attachment 158740 [details] [review] adding back volatile to g_atomic_* casts fixes this test case: $ echo "#include <glib.h>" > tmp.c $ gcc -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -Wcast-qual -Werror -c -o /dev/null tmp.c cc1: warnings being treated as errors In file included from /usr/include/glib-2.0/glib/gasyncqueue.h:34, from /usr/include/glib-2.0/glib.h:34, from tmp.c:1: /usr/include/glib-2.0/glib/gthread.h: In function ‘g_once_init_enter’: /usr/include/glib-2.0/glib/gthread.h:348: error: cast discards qualifiers from pointer target type
Broken again with http://git.gnome.org/browse/glib/commit/?id=c8e37b63e74fafdc1f299ec139677ad0e37676c3 test case: echo "#include <glib.h>" > tmp.c gcc -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -Wcast-qual -Werror -c -o /dev/null tmp.c cc1: warnings being treated as errors In file included from /usr/include/glib-2.0/glib/gasyncqueue.h:34, from /usr/include/glib-2.0/glib.h:34, from tmp.c:1: /usr/include/glib-2.0/glib/gthread.h: In function ‘g_once_init_enter’: /usr/include/glib-2.0/glib/gthread.h:348: error: cast discards qualifiers from pointer target type (debian sid amd64 system, but git pickaxe suggests that it would be the same every where else). Actual projects affected for me: heartbeat, cluster-glue. gcc -E results suggests that the problem is somewhere in here: static __inline __attribute__ ((unused)) gboolean g_once_init_enter (volatile gsize *value_location) { if ((gpointer) ((void) sizeof (gchar [sizeof (*(value_location)) == sizeof (gpointer) ? 1 : -1]), (g_atomic_pointer_get) ((volatile gpointer __attribute__((may_alias)) *) (void * volatile) (value_location))) != ((void *)0)) return (0); else return g_once_init_enter_impl (value_location); } namely the expansion of the g_atomic_pointer_get. I suggest the patch I just attached to this bug. (only checked against above test case yet, not against the actually affected projects)
Reopening as per last comments.
The following fixes have been pushed:
I love git-bz. Anyway, I pushed your fix to master.