avoid warning in gutils.h when using gcc with -Wconversion
authorHannes Mueller <h.c.f.mueller@gmx.de>
Sat, 4 Feb 2012 09:06:35 +0000 (10:06 +0100)
committerBenjamin Otte <otte@redhat.com>
Tue, 17 Apr 2012 16:24:41 +0000 (18:24 +0200)
Old solution to avoid warning with gcc flag -Wconversion does not
work with gcc >=4.3 since the behaviour for that flag has been
changed, ref. http://gcc.gnu.org/wiki/NewWconversion. Now cast for
__builtin_clzl is required, which itself is declared to return int.

https://bugzilla.gnome.org/show_bug.cgi?id=619026

glib/gutils.h

index 95114d8..1dd5e56 100644 (file)
@@ -304,7 +304,7 @@ g_bit_storage (gulong number)
 {
 #if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__OPTIMIZE__)
   return G_LIKELY (number) ?
-          ((GLIB_SIZEOF_LONG * 8U - 1) ^ __builtin_clzl(number)) + 1 : 1;
+          ((GLIB_SIZEOF_LONG * 8U - 1) ^ (guint) __builtin_clzl(number)) + 1 : 1;
 #else
   register guint n_bits = 0;