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 775112 - clang compiler warnings due to integer conversions
clang compiler warnings due to integer conversions
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: orc
git master
Other Linux
: Normal blocker
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-11-25 18:53 UTC by Hanno Böck
Modified: 2017-11-13 14:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
orc: Explicitly define unsigned integer literals as unsigned (9.00 KB, patch)
2016-11-26 09:39 UTC, Sebastian Dröge (slomo)
needs-work Details | Review

Description Hanno Böck 2016-11-25 18:53:11 UTC
By default the git code of the gstreamer modules enables -Werror, so all compiler warnings are fatal.

Compiling with clang causes several compiler warnings related to integer casts:
tmp-orc.c:931:13: error: implicit conversion from 'int' to 'orc_int8' (aka 'signed char') changes value from 255 to
      -1 [-Werror,-Wconstant-conversion]
    var36 = (int)0x000000ff; /* 255 or 1.25987e-321f */
          ~ ^~~~~~~~~~~~~~~
tmp-orc.c:1504:19: error: implicit conversion from 'int' to 'orc_int8' (aka 'signed char') changes value from 255 to
      -1 [-Werror,-Wconstant-conversion]
    var37.x2[0] = (int)0x000000ff; /* 255 or 1.25987e-321f */
                ~ ^~~~~~~~~~~~~~~
tmp-orc.c:1505:19: error: implicit conversion from 'int' to 'orc_int8' (aka 'signed char') changes value from 255 to
      -1 [-Werror,-Wconstant-conversion]
    var37.x2[1] = (int)0x000000ff; /* 255 or 1.25987e-321f */
                ~ ^~~~~~~~~~~~~~~
tmp-orc.c:2128:19: error: implicit conversion from 'int' to 'orc_int8' (aka 'signed char') changes value from 255 to
      -1 [-Werror,-Wconstant-conversion]
    var37.x2[0] = (int)0x000000ff; /* 255 or 1.25987e-321f */
                ~ ^~~~~~~~~~~~~~~
tmp-orc.c:2129:19: error: implicit conversion from 'int' to 'orc_int8' (aka 'signed char') changes value from 255 to
      -1 [-Werror,-Wconstant-conversion]
    var37.x2[1] = (int)0x000000ff; /* 255 or 1.25987e-321f */
                ~ ^~~~~~~~~~~~~~~
tmp-orc.c:2563:19: error: implicit conversion from 'int' to 'orc_int8' (aka 'signed char') changes value from 255 to
      -1 [-Werror,-Wconstant-conversion]
    var37.x2[0] = (int)0x000000ff; /* 255 or 1.25987e-321f */
                ~ ^~~~~~~~~~~~~~~
tmp-orc.c:2564:19: error: implicit conversion from 'int' to 'orc_int8' (aka 'signed char') changes value from 255 to
      -1 [-Werror,-Wconstant-conversion]
    var37.x2[1] = (int)0x000000ff; /* 255 or 1.25987e-321f */
                ~ ^~~~~~~~~~~~~~~
tmp-orc.c:2794:19: error: implicit conversion from 'int' to 'orc_int8' (aka 'signed char') changes value from 255 to
      -1 [-Werror,-Wconstant-conversion]
    var37.x2[0] = (int)0x000000ff; /* 255 or 1.25987e-321f */
                ~ ^~~~~~~~~~~~~~~
tmp-orc.c:2795:19: error: implicit conversion from 'int' to 'orc_int8' (aka 'signed char') changes value from 255 to
      -1 [-Werror,-Wconstant-conversion]
    var37.x2[1] = (int)0x000000ff; /* 255 or 1.25987e-321f */
                ~ ^~~~~~~~~~~~~~~
tmp-orc.c:3236:19: error: implicit conversion from 'int' to 'orc_int8' (aka 'signed char') changes value from 255 to
      -1 [-Werror,-Wconstant-conversion]
    var37.x2[0] = (int)0x000000ff; /* 255 or 1.25987e-321f */
                ~ ^~~~~~~~~~~~~~~
tmp-orc.c:3237:19: error: implicit conversion from 'int' to 'orc_int8' (aka 'signed char') changes value from 255 to
      -1 [-Werror,-Wconstant-conversion]
    var37.x2[1] = (int)0x000000ff; /* 255 or 1.25987e-321f */
                ~ ^~~~~~~~~~~~~~~
tmp-orc.c:3474:19: error: implicit conversion from 'int' to 'orc_int8' (aka 'signed char') changes value from 255 to
      -1 [-Werror,-Wconstant-conversion]
    var38.x2[0] = (int)0x000000ff; /* 255 or 1.25987e-321f */
                ~ ^~~~~~~~~~~~~~~
tmp-orc.c:3475:19: error: implicit conversion from 'int' to 'orc_int8' (aka 'signed char') changes value from 255 to
      -1 [-Werror,-Wconstant-conversion]
    var38.x2[1] = (int)0x000000ff; /* 255 or 1.25987e-321f */
                ~ ^~~~~~~~~~~~~~~
tmp-orc.c:3895:13: error: implicit conversion from 'int' to 'orc_int8' (aka 'signed char') changes value from 255 to
      -1 [-Werror,-Wconstant-conversion]
    var36 = (int)0x000000ff; /* 255 or 1.25987e-321f */
          ~ ^~~~~~~~~~~~~~~
tmp-orc.c:4241:13: error: implicit conversion from 'int' to 'orc_int8' (aka 'signed char') changes value from 255 to
      -1 [-Werror,-Wconstant-conversion]
    var33 = (int)0x000000ff; /* 255 or 1.25987e-321f */
          ~ ^~~~~~~~~~~~~~~
tmp-orc.c:4243:15: error: implicit conversion from 'int' to 'orc_int16' (aka 'short') changes value from 32896 to
      -32640 [-Werror,-Wconstant-conversion]
    var35.i = (int)0x00008080; /* 32896 or 1.62528e-319f */
            ~ ^~~~~~~~~~~~~~~
tmp-orc.c:5252:19: error: implicit conversion from 'int' to 'orc_int8' (aka 'signed char') changes value from 255 to
      -1 [-Werror,-Wconstant-conversion]
    var36.x2[0] = (int)0x000000ff; /* 255 or 1.25987e-321f */
                ~ ^~~~~~~~~~~~~~~
tmp-orc.c:5253:19: error: implicit conversion from 'int' to 'orc_int8' (aka 'signed char') changes value from 255 to
      -1 [-Werror,-Wconstant-conversion]
    var36.x2[1] = (int)0x000000ff; /* 255 or 1.25987e-321f */
                ~ ^~~~~~~~~~~~~~~
tmp-orc.c:5639:19: error: implicit conversion from 'int' to 'orc_int8' (aka 'signed char') changes value from 255 to
      -1 [-Werror,-Wconstant-conversion]
    var36.x2[0] = (int)0x000000ff; /* 255 or 1.25987e-321f */
                ~ ^~~~~~~~~~~~~~~
Comment 1 Sebastian Dröge (slomo) 2016-11-25 19:17:47 UTC
That should still be doing what is intended, but we should fix orc to generate code for this properly
Comment 2 Sebastian Dröge (slomo) 2016-11-26 09:39:27 UTC
Created attachment 340787 [details] [review]
orc: Explicitly define unsigned integer literals as unsigned

And cast constant loads to their correct target type instead of int. clang
complains about such implicit conversions in the latest version:

error: implicit conversion from 'int' to 'orc_int8' (aka 'signed char') changes value from 255 to
      -1 [-Werror,-Wconstant-conversion]
    var36 = (int)0x000000ff; /* 255 or 1.25987e-321f */
Comment 3 Sebastian Dröge (slomo) 2016-11-26 09:44:21 UTC
Comment on attachment 340787 [details] [review]
orc: Explicitly define unsigned integer literals as unsigned

This fixes the compiler warnings but breaks the tests, also with gcc this time (with clang they are broken anyway, orc does not work with clang, see bug #728129, bug #728738).

The C backend should really be cleaned up for this, with clang becoming more common and compilers becoming more irrational with regard to undefined behaviour.


The simplest way to solve this seems to be to rewrite all the generated code so that each variable and constant has an explicit cast to the expected type first (which we know anyway). And then we can start fixing up implementations that now fail.
Comment 4 Edward Hervey 2017-11-13 09:30:19 UTC
Just rebuild orc with clang ... and it doesn't seem to fail anymore. Can someone else confirm ?
Comment 5 Sebastian Dröge (slomo) 2017-11-13 09:38:26 UTC
Works here with clang 3.9.1 (also the tests succeed now). Will try with a newer version later.
Comment 6 Hanno Böck 2017-11-13 11:07:56 UTC
I just tried to build the gstreamer module from git and it fails with a different error regarding linking, so I can't re-test this right now:

make[4]: Entering directory '/mnt/ram/gstreamer/gst'
  GEN      Gst-1.0.gir
g-ir-scanner: link: /bin/sh ../libtool --mode=link --tag=CC clang -o /mnt/ram/gstreamer/gst/tmp-introspectzxs68ceb/Gst-1.0 -export-dynamic -g -O2 tmp-introspectzxs68ceb/mnt/ram/gstreamer/gst/tmp-introspectzxs68ceb/Gst-1.0.o -L. libgstreamer-1.0.la -lgio-2.0 -Wl,--export-dynamic -lgmodule-2.0 -pthread -lgobject-2.0 -lgmodule-2.0 -pthread -lglib-2.0
libtool: link: clang -o /mnt/ram/gstreamer/gst/tmp-introspectzxs68ceb/.libs/Gst-1.0 -g -O2 tmp-introspectzxs68ceb/mnt/ram/gstreamer/gst/tmp-introspectzxs68ceb/Gst-1.0.o -Wl,--export-dynamic -pthread -pthread  -L. ./.libs/libgstreamer-1.0.so /usr/lib64/libunwind.so -lc -lgcc_s -ldw -lelf -lm -lrt -ldl -lgio-2.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -pthread
clang-5.0: error: no such file or directory: './.libs/libgstreamer-1.0.so'
linking of temporary binary failed: Command '['/bin/sh', '../libtool', '--mode=link', '--tag=CC', 'clang', '-o', '/mnt/ram/gstreamer/gst/tmp-introspectzxs68ceb/Gst-1.0', '-export-dynamic', '-g', '-O2', 'tmp-introspectzxs68ceb/mnt/ram/gstreamer/gst/tmp-introspectzxs68ceb/Gst-1.0.o', '-L.', 'libgstreamer-1.0.la', '-lgio-2.0', '-Wl,--export-dynamic', '-lgmodule-2.0', '-pthread', '-lgobject-2.0', '-lgmodule-2.0', '-pthread', '-lglib-2.0']' returned non-zero exit status 1
Comment 7 Edward Hervey 2017-11-13 13:35:58 UTC
(In reply to Sebastian Dröge (slomo) from comment #5)
> Works here with clang 3.9.1 (also the tests succeed now). Will try with a
> newer version later.

Cool !

(In reply to Hanno Boeck from comment #6)
> I just tried to build the gstreamer module from git and it fails with a
> different error regarding linking, so I can't re-test this right now:
> 

Hanno, this looks like it's a completely different error. Ok to open a new bug report for that ?
Comment 8 Sebastian Dröge (slomo) 2017-11-13 13:51:48 UTC
Hanno's error is because he configured with CC=clang-5.0 but there is no clang-5.0 available on his system anymore. No bug there.

Before closing this, someone should try with clang 5.0 or newer, I'll do so later today if nobody else is faster.
Comment 9 Edward Hervey 2017-11-13 14:32:12 UTC
Just did a full orc+gst* build with clang-5. Closing.

Hanno, if you still see issues, please open a new bug report, thanks.