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 767883 - Bit shift overflow (-Wshift-overflow) warning in gstmessage.h
Bit shift overflow (-Wshift-overflow) warning in gstmessage.h
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: common
1.8.2
Other Linux
: Normal minor
: 1.10.0
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-06-20 18:23 UTC by Andrew Eikum
Modified: 2016-10-31 14:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gstmessage.h: Avoid gcc bit shift overflow warning (-Wshift-overflow) (902 bytes, patch)
2016-06-21 13:02 UTC, Andrew Eikum
committed Details | Review

Description Andrew Eikum 2016-06-20 18:23:20 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.
Comment 1 Sebastian Dröge (slomo) 2016-06-21 07:31:40 UTC
Does it work if the 1 is casted to an unsigned int before shifting?
Comment 2 Andrew Eikum 2016-06-21 12:22:15 UTC
Yes, a change to "1u << 31" gets gcc to stop complaining.
Comment 3 Sebastian Dröge (slomo) 2016-06-21 12:56:14 UTC
Do you want to provide a patch?
Comment 4 Andrew Eikum 2016-06-21 13:02:12 UTC
Created attachment 330130 [details] [review]
gstmessage.h: Avoid gcc bit shift overflow warning (-Wshift-overflow)

Sure
Comment 5 Tim-Philipp Müller 2016-10-24 10:52:05 UTC
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 6 Tim-Philipp Müller 2016-10-24 10:52:40 UTC
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.