GNOME Bugzilla – Bug 767883
Bit shift overflow (-Wshift-overflow) warning in gstmessage.h
Last modified: 2016-10-31 14:33:29 UTC
When building 32-bit Wine with gstreamer, I get this warning with gcc 6.1.1 20160602: gcc -m32 -c -o gstdemux.o gstdemux.c -I. -I../../include -I/usr/include/gstreamer-1.0 \ -I/usr/lib32/gstreamer-1.0/include -I/usr/include/glib-2.0 -I/usr/lib32/glib-2.0/include \ -D__WINESRC__ -D_REENTRANT -fPIC -Wall -pipe -fno-strict-aliasing -Wdeclaration-after-statement \ -Wempty-body -Wignored-qualifiers -Wshift-overflow=2 -Wstrict-prototypes -Wtype-limits \ -Wunused-but-set-parameter -Wvla -Wwrite-strings -Wpointer-arith -Wlogical-op -gdwarf-2 \ -gstrict-dwarf -fno-omit-frame-pointer -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 In file included from /usr/include/gstreamer-1.0/gst/gstevent.h:184:0, from /usr/include/gstreamer-1.0/gst/gstpadtemplate.h:36, from /usr/include/gstreamer-1.0/gst/gstpad.h:72, from /usr/include/gstreamer-1.0/gst/gstelement.h:57, from /usr/include/gstreamer-1.0/gst/gstbin.h:27, from /usr/include/gstreamer-1.0/gst/gst.h:35, from gstdemux.c:24: /usr/include/gstreamer-1.0/gst/gstmessage.h:156:29: warning: result of ‘1 << 31’ requires 33 bits to represent, but ‘int’ only has 32 bits [-Wshift-overflow=] GST_MESSAGE_EXTENDED = (1 << 31), Enums are defined to be "int" so putting this bit there hits the sign flag, which gcc doesn't like. Maybe it should use some method other than bit-shift to set that bit. Even just disabling the warning would probably be fine. See also Bug 767882 in glib2.
Does it work if the 1 is casted to an unsigned int before shifting?
Yes, a change to "1u << 31" gets gcc to stop complaining.
Do you want to provide a patch?
Created attachment 330130 [details] [review] gstmessage.h: Avoid gcc bit shift overflow warning (-Wshift-overflow) Sure
commit ec4c76f297e03f78731278c4bd8e3c56364f8e82 Author: Andrew Eikum <aeikum@codeweavers.com> Date: Tue Jun 21 08:00:30 2016 -0500 gstmessage.h: Avoid gcc bit shift overflow compiler warning Avoids bit shift overflow warning with gcc6. https://bugzilla.gnome.org/show_bug.cgi?id=767882 (glib) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71803 (gcc) https://bugzilla.gnome.org/show_bug.cgi?id=767883 tp
Comment on attachment 330130 [details] [review] gstmessage.h: Avoid gcc bit shift overflow warning (-Wshift-overflow) committed with an additional (gint) cast like done in GLib and for GST_MESSAGE_ANY.