Debian Bug report logs - #812138
pyqwt3d: FTBFS with GCC 6: narrowing conversion

version graph

Package: pyqwt3d; Maintainer for pyqwt3d is Gudjon I. Gudjonsson <gudjon@gudjon.org>;

Affects: python-qwt3d-qt4

Reported by: Martin Michlmayr <tbm@cyrius.com>

Date: Wed, 20 Jan 2016 23:27:01 UTC

Severity: serious

Tags: buster, sid, stretch

Found in version 0.1.7~cvs20090625-13

Reply or subscribe to this bug.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Gudjon I. Gudjonsson <gudjon@gudjon.org>:
Bug#812138; Package pyqwt3d. (Wed, 20 Jan 2016 23:27:05 GMT) (full text, mbox, link).


Acknowledgement sent to Martin Michlmayr <tbm@hpe.com>:
New Bug report received and forwarded. Copy sent to Gudjon I. Gudjonsson <gudjon@gudjon.org>. (Wed, 20 Jan 2016 23:27:05 GMT) (full text, mbox, link).


Message #5 received at submit@bugs.debian.org (full text, mbox, reply):

From: Martin Michlmayr <tbm@hpe.com>
To: submit@bugs.debian.org
Subject: pyqwt3d: FTBFS with GCC 6: narrowing conversion
Date: Wed, 20 Jan 2016 15:23:21 -0800
Package: pyqwt3d
Version: 0.1.7~cvs20090625-13
Severity: important
User: debian-gcc@lists.debian.org
Usertags: ftbfs-gcc-6 gcc-6-narrowing

This package fails to build with GCC 6.  GCC 6 has not been released
yet, but it's expected that GCC 6 will become the default compiler for
stretch.

Note that only the first error is reported; there might be more.  You
can find a snapshot of GCC 6 in experimental.  To build with GCC 6,
you can set CC=gcc-6 CXX=g++-6 explicitly.

You may be able to find out more about this issue at
https://gcc.gnu.org/gcc-6/changes.html

> sbuild (Debian sbuild) 0.67.0 (26 Dec 2015) on dl580gen9-02.hlinux
...
> make[2]: Entering directory '/<<PKGBUILDDIR>>/build/py2.7-qt4/configure/OpenGL_Qt4'
> g++ -c -g -O2 -fstack-protector-strong -Wformat -Werror=format-security  -D_FORTIFY_SOURCE=2 -fPIC -O2 -Wall -W -D_REENTRANT -DNDEBUG -DGL2PS_HAVE_ZLIB -DHAS_NUMPY -DQT_NO_DEBUG -DQT_OPENGL_LIB -I. -I/usr/include/qwtplot3d-qt4 -I/usr/include/python2.7 -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/qt4/Qt -I/usr/share/qt4/mkspecs/default -I/usr/include/qt4/QtOpenGL -I/usr/include/qt4 -I/usr/X11R6/include -o sipOpenGLcmodule.o sipOpenGLcmodule.cpp
> sipOpenGLcmodule.cpp:4447:1: error: narrowing conversion of '4294967295u' from 'unsigned int' to 'int' inside { } [-Wnarrowing]
>  };
>  ^
> 
> sipOpenGLcmodule.cpp:4447:1: error: narrowing conversion of '4294967295u' from 'unsigned int' to 'int' inside { } [-Wnarrowing]
> Makefile:18: recipe for target 'sipOpenGLcmodule.o' failed
> make[2]: *** [sipOpenGLcmodule.o] Error 1
> make[2]: Leaving directory '/<<PKGBUILDDIR>>/build/py2.7-qt4/configure/OpenGL_Qt4'

-- 
Martin Michlmayr
Linux for HPE Helion, Hewlett Packard Enterprise



Severity set to 'serious' from 'important' Request was from Matthias Klose <doko@debian.org> to control@bugs.debian.org. (Wed, 29 Jun 2016 13:13:20 GMT) (full text, mbox, link).


Added tag(s) stretch and sid. Request was from Andreas Beckmann <anbe@debian.org> to control@bugs.debian.org. (Fri, 01 Jul 2016 00:30:10 GMT) (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, Gudjon I. Gudjonsson <gudjon@gudjon.org>:
Bug#812138; Package pyqwt3d. (Mon, 15 Aug 2016 11:27:06 GMT) (full text, mbox, link).


Acknowledgement sent to gudjon@gudjon.org:
Extra info received and forwarded to list. Copy sent to Gudjon I. Gudjonsson <gudjon@gudjon.org>. (Mon, 15 Aug 2016 11:27:06 GMT) (full text, mbox, link).


Message #14 received at 812138@bugs.debian.org (full text, mbox, reply):

From: "Gudjon I. Gudjonsson" <gudjon@gudjon.org>
To: 812138@bugs.debian.org, Debian Mentors List <debian-mentors@lists.debian.org>
Subject: gcc-6 and sip help (bug 812138)
Date: Mon, 15 Aug 2016 12:43:08 +0200
Hi list

I am trying to fix a sip/gcc-6 related bug in package pyqwt3d but I don't know 
how.

OpeGL_mod.sip contains

const int GL_2D;
const int GL_3D;
const int GL_3D_COLOR;
....

which is converted to

sipOpenGLcmodule.cpp which contains:

static sipIntInstanceDef intInstances[] = {
    {sipName_GL_2D, GL_2D},
    {sipName_GL_2_BYTES, GL_2_BYTES},
    {sipName_GL_3D, GL_3D},
    ......
    {0, 0}
};

This fails to compile with the following message:

make[2]: Entering directory '/home/gudjon/nb/pyqwt3d/
pyqwt3d-0.1.7~cvs20090625/build/py2.7-qt4/configure/OpenGL_Qt4'
g++ -c -g -O2 -fstack-protector-strong -Wformat -Werror=format-security  -
Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -O2 -Wall -W -D_REENTRANT -DNDEBUG -
DGL2PS_HAVE_ZLIB -DHAS_NUMPY -DQT_NO_DEBUG -DQT_OPENGL_LIB -I. -I/usr/include/
qwtplot3d-qt4 -I/usr/include/python2.7 -I/usr/lib/python2.7/dist-packages/
numpy/core/include -I/usr/include/qt4/Qt -I/usr/share/qt4/mkspecs/default -I/
usr/include/qt4/QtOpenGL -I/usr/include/qt4 -I/usr/X11R6/include -o 
sipOpenGLcmodule.o sipOpenGLcmodule.cpp
sipOpenGLcmodule.cpp:4445:1: error: narrowing conversion of ‘4294967295u’ from 
‘unsigned int’ to ‘int’ inside { } [-Wnarrowing]
 };


sipIntInstanceDef is defined in:
/usr/include/python2.7/sip.h

typedef struct _sipIntInstanceDef {
    /* The int name. */
    const char *ii_name;

    /* The int value. */
    int ii_val;
} sipIntInstanceDef;


But some of the OpenGL parameters are out of range for int.


Does anyone have a clue on how to fix this?

Regards
Gudjon





Information forwarded to debian-bugs-dist@lists.debian.org, Gudjon I. Gudjonsson <gudjon@gudjon.org>:
Bug#812138; Package pyqwt3d. (Mon, 15 Aug 2016 12:33:06 GMT) (full text, mbox, link).


Acknowledgement sent to Christian Seiler <christian@iwakd.de>:
Extra info received and forwarded to list. Copy sent to Gudjon I. Gudjonsson <gudjon@gudjon.org>. (Mon, 15 Aug 2016 12:33:06 GMT) (full text, mbox, link).


Message #19 received at 812138@bugs.debian.org (full text, mbox, reply):

From: Christian Seiler <christian@iwakd.de>
To: gudjon@gudjon.org, 812138@bugs.debian.org, Debian Mentors List <debian-mentors@lists.debian.org>
Subject: Re: gcc-6 and sip help (bug 812138)
Date: Mon, 15 Aug 2016 14:29:09 +0200
On 08/15/2016 12:43 PM, Gudjon I. Gudjonsson wrote:
> This fails to compile with the following message:
> 
> make[2]: Entering directory '/home/gudjon/nb/pyqwt3d/
> pyqwt3d-0.1.7~cvs20090625/build/py2.7-qt4/configure/OpenGL_Qt4'
> g++ -c -g -O2 -fstack-protector-strong -Wformat -Werror=format-security  -
> Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -O2 -Wall -W -D_REENTRANT -DNDEBUG -
> DGL2PS_HAVE_ZLIB -DHAS_NUMPY -DQT_NO_DEBUG -DQT_OPENGL_LIB -I. -I/usr/include/
> qwtplot3d-qt4 -I/usr/include/python2.7 -I/usr/lib/python2.7/dist-packages/
> numpy/core/include -I/usr/include/qt4/Qt -I/usr/share/qt4/mkspecs/default -I/
> usr/include/qt4/QtOpenGL -I/usr/include/qt4 -I/usr/X11R6/include -o 
> sipOpenGLcmodule.o sipOpenGLcmodule.cpp
> sipOpenGLcmodule.cpp:4445:1: error: narrowing conversion of ‘4294967295u’ from 
> ‘unsigned int’ to ‘int’ inside { } [-Wnarrowing]
>  };

Beginning with gcc 5, when using the newest C++ standard, narrowing
conversions of constants are an error:

https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html
   (search for "-Wnarrowing")
https://gcc.gnu.org/wiki/FAQ#Why_does_GCC_not_give_an_error_for_some_narrowing_conversions_within_list-initializations_as_required_by_C.2B-.2B-11_.28-Wnarrowing.29_.3F

Starting with gcc 6, the default C++ standard the compiler uses is
now gnu++14 (i.e. C++14 + GNU extensions). IIRC the default standard
the compiler assumed previously was still C++98. (I may be wrong
though.)

Now obviously, the problem is with the original sip file: int is
simply the wrong data type for these constants. You should use
unsigned int instead.

However, it appears that only two constants are affected here, and
the error message is actually quite misleading about the position
of the error, because sip creates a large data structure, and the
position where the error is thrown is at the end of the definition
of the data structure. If you investigate the constants that are
defined in that data structure further though, you'll realize that
only two are actually >= 0x80000000, i.e. don't fit in a signed int
anymore.

Those are:

GL_CLIENT_ALL_ATTRIB_BITS
GL_ALL_ATTRIB_BITS

which both are defined as 0xFFFFFFFF in GL/gl.h, to indicate that
all bits (that fit into 32bit int[0]) are meant.

The proper fix would probably be to replace all int constants with
unsigned int constants, but that has two issues:

 - sip doesn't appear to make a difference between int and unsigned
   int (it uses int internally), so that doesn't actually help

 - you don't want to touch the entire source file
   (ok, you could touch only those two constants, but that would
   be asymmetric)

You could probably resort to long long as a data type (long is not
sufficient on 32bit platfors), but that's really not a good idea
IMHO.

The easiest solution is probably to add -Wno-narrowing to the
compiler flags. Now due to the fact that how your pacakge build
works [1], you actually have to add 

  --extra-cxxflags="-Wno-narrowing"

to the configure.py invocation in debian/rules (for example you can
put it before --extra-libs=...). That disables the compiler
diagnostic and makes the package compile again. I just tried that
and it does build the package. [2]

However, and this was actually also a bug in the previous version
of the package, the two constants are defined "wrongly" in Python:

>>> import PyQt4.Qwt3D.OpenGL
>>> PyQt4.Qwt3D.OpenGL.GL_CLIENT_ALL_ATTRIB_BITS
-1
>>> PyQt4.Qwt3D.OpenGL.GL_ALL_ATTRIB_BITS
-1

(Should be 4294967295, if they really were unsigned.)

It's not terribly problematic, because using those constants with
a bitwise AND in python will result in the correct answer:

>>> PyQt4.Qwt3D.OpenGL.GL_ALL_ATTRIB_BITS & PyQt4.Qwt3D.OpenGL.GL_2D == PyQt4.Qwt3D.OpenGL.GL_2D
True

But a really proper fix for this would entail:

 - file a bug against sip to support unsigned int properly
 - once that's fixed, remove the -Wno-narrowing against in your
   package and use unsigned int for all of the constants, not a
   signed int (at least for those constants that are obviously
   meant to be used in a bit field context)

Hope that helps.
	
Regards,
Christian

[0] Which in theory is not completely portable, because int could
    be larger or smaller than 32 bits (though in practice it isn't
    on any arch Debian supports), the right way to define a
    constant for "all bits in an unsigned int" would be to use
    #define CONSTANT_NAME (~0u)
    However, that's probably something one should tell OpenGL
    upstream, because it's there that that constant is defined in
    that way.

[1] Btw. the entire CFLAGS = logic in debian/rules you can drop,
    because a) you're compiling C++ code, so CXXFLAGS would be
    relevant and b) the way python builds its modules is that it
    always uses the compiler and flags that python itself was
    compiled with (and it's non-trivial to override that), so
    even CXXFLAGS would likely have no effect at all.

[2] There's a reason for this diagnostic though, and I expect
    that previous build logs will have already shown that warning.
    In your case the warning can be ignored (because these type
    of "all bit" constants are rather harmless), but that's not
    always true.



Changed Bug submitter to 'Martin Michlmayr <tbm@cyrius.com>' from 'Martin Michlmayr <tbm@hpe.com>'. Request was from Martin Michlmayr <tbm@hpe.com> to control@bugs.debian.org. (Thu, 26 Jan 2017 19:50:23 GMT) (full text, mbox, link).


Added tag(s) buster. Request was from ivodd@debian.org to control@bugs.debian.org. (Sun, 18 Jun 2017 09:55:23 GMT) (full text, mbox, link).


Added indication that 812138 affects python-qwt3d-qt4 Request was from Andreas Beckmann <anbe@debian.org> to control@bugs.debian.org. (Mon, 02 Oct 2017 03:27:05 GMT) (full text, mbox, link).


Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Wed Jan 10 11:22:59 2018; Machine Name: buxtehude

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.