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 457641 - glib-2.13.7: C++ conversion problem in gthread.h
glib-2.13.7: C++ conversion problem in gthread.h
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gthread
2.13.x
Other Linux
: Normal blocker
: ---
Assigned To: Tim Janik
gtkdev
: 458025 459077 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2007-07-17 14:05 UTC by Joseph Sacco
Modified: 2010-04-15 17:08 UTC
See Also:
GNOME target: ---
GNOME version: 2.19/2.20


Attachments
adding back volatile to g_atomic_* casts (1.49 KB, patch)
2010-04-14 18:29 UTC, Lars Ellenberg
committed Details | Review

Description Joseph Sacco 2007-07-17 14:05:22 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'
Comment 1 Kaj-Michael Lang 2007-07-22 12:42:25 UTC
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
Comment 2 Sebastien Bacher 2007-07-24 08:22:47 UTC
*** Bug 458025 has been marked as a duplicate of this bug. ***
Comment 3 Sebastien Bacher 2007-07-24 08:23:02 UTC
*** Bug 459077 has been marked as a duplicate of this bug. ***
Comment 4 Loïc Minier 2007-07-27 12:03:38 UTC
I'm bumping the severity to blocker as it prevents other apps from building on these arches (such as gtk).
Comment 5 Sebastien Bacher 2007-07-27 14:05:20 UTC
That has already been fixed to SVN for some time, http://svn.gnome.org/viewcvs/glib?view=revision&revision=5637
Comment 6 Erik van Pienbroek 2007-08-21 19:06:08 UTC
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
Comment 7 Tim Janik 2007-08-23 10:06:20 UTC
(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
> 

Comment 8 Tim Janik 2007-08-23 10:07:49 UTC
(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);
Comment 9 Sjoerd Simons 2007-08-24 12:21:40 UTC
(In reply to comment #8)
This does indeed fix compiling wireshark from svn for me.
Comment 10 Tim Janik 2007-08-29 10:12:05 UTC
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.

Comment 11 Lars Ellenberg 2010-04-14 18:29:21 UTC
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
Comment 12 Lars Ellenberg 2010-04-14 18:31:03 UTC
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)
Comment 13 Tobias Mueller 2010-04-14 23:15:17 UTC
Reopening as per last comments.
Comment 14 Benjamin Otte (Company) 2010-04-15 17:06:37 UTC
The following fixes have been pushed:
Comment 15 Benjamin Otte (Company) 2010-04-15 17:07:54 UTC
I love git-bz.
Anyway, I pushed your fix to master.