Bug 1473425
Summary: | gcc7 throws error on pymem.h (python2-devel) macros | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Gabriel Somlo <somlo> | ||||||
Component: | python2 | Assignee: | Petr Viktorin (pviktori) <pviktori> | ||||||
Status: | CLOSED ERRATA | QA Contact: | Fedora Extras Quality Assurance <extras-qa> | ||||||
Severity: | unspecified | Docs Contact: | |||||||
Priority: | unspecified | ||||||||
Version: | 27 | CC: | bkabrda, cstratak, dmalcolm, igal, mcyprian, mhroncok, pviktori, rkuska, tomspur, torsava | ||||||
Target Milestone: | --- | ||||||||
Target Release: | --- | ||||||||
Hardware: | Unspecified | ||||||||
OS: | Unspecified | ||||||||
Whiteboard: | |||||||||
Fixed In Version: | python2-2.7.14-8.fc27 | Doc Type: | If docs needed, set a value | ||||||
Doc Text: | Story Points: | --- | |||||||
Clone Of: | Environment: | ||||||||
Last Closed: | 2018-03-06 17:29:59 UTC | Type: | Bug | ||||||
Regression: | --- | Mount Type: | --- | ||||||
Documentation: | --- | CRM: | |||||||
Verified Versions: | Category: | --- | |||||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||||
Cloudforms Team: | --- | Target Upstream Version: | |||||||
Embargoed: | |||||||||
Attachments: |
|
Could you provide a minimal example of a program to compile with those macros? Also this certainly looks like a good candidate for an upstream pull request. Created attachment 1302514 [details] file on which warning emitted with -Wall compile with "gcc -Wall -I/usr/include/python2.7 -c netnsmodule.c" On F26, this emits the warning described earlier. The file is part of the CORE network simulator (https://github.com/coreemu/core). I'm trying to build it as an RPM package using mock, a process that results in "-Wall -Werror" being specified on the gcc command line, which makes the rpm build process fail. So this is due to the new warning [0] with gcc 7: -Wint-in-bool-context warns about suspicious uses of integer values where boolean values are expected. This warning is enabled by -Wall. [0] https://gcc.gnu.org/gcc-7/changes.html This should be addressed upstream first preferably. Would be you be able to open a new issue at http://bugs.python.org/ ? Maybe sent a pull request? I can guide you through the procedures if required or I can take over at any step you'd prefer. This bug appears to have been reported against 'rawhide' during the Fedora 27 development cycle. Changing version to '27'. I'm getting the same error when trying to compile CORE Network Emulator (https://github.com/coreemu/core) with gcc7 on Fedora 26: gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -O3 -Werror -Wall -D_GNU_SOURCE -fPIC -I/usr/include/python2.7 -c netnsmodule.c -o build/temp.linux-x86_64-2.7/netnsmodule.o In file included from /usr/include/python2.7/Python.h:78:0, from netnsmodule.c:16: netnsmodule.c: In function ‘netns_nsexecvp’: /usr/include/python2.7/pymem.h:97:30: error: ‘*’ in boolean context, suggest ‘&&’ instead [-Werror=int-in-bool-context] ( (type *) PyMem_MALLOC((n) * sizeof(type)) ) ) ^ /usr/include/python2.7/pymem.h:75:15: note: in definition of macro ‘PyMem_MALLOC’ : malloc((n) ? (n) : 1)) ^ netnsmodule.c:61:10: note: in expansion of macro ‘PyMem_NEW’ argv = PyMem_NEW(char *, argc + 1); ^~~~~~~~~ cc1: all warnings being treated as errors error: command 'gcc' failed with exit status 1 make[3]: *** [Makefile:695: libnetns.a] Error 1 make[3]: Leaving directory '/home/user/Downloads/core/daemon/src' make[2]: *** [Makefile:637: all-recursive] Error 1 make[2]: Leaving directory '/home/user/Downloads/core/daemon' make[1]: *** [Makefile:459: all-recursive] Error 1 make[1]: Leaving directory '/home/user/Downloads/core' make: *** [Makefile:387: all] Error 2 Solved in https://github.com/python/cpython/pull/3581 and should be part of Python 2.7.15 I'll prepare a backport for Fedora. python2-2.7.14-8.fc27 has been submitted as an update to Fedora 27. https://bodhi.fedoraproject.org/updates/FEDORA-2018-76e9d22b5c Fixed in Rawhide and Fedora 28. For f27, please test and add karma :) https://bodhi.fedoraproject.org/updates/FEDORA-2018-76e9d22b5c python2-2.7.14-8.fc27 has been pushed to the Fedora 27 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-76e9d22b5c python2-2.7.14-8.fc27 has been pushed to the Fedora 27 stable repository. If problems still persist, please make note of it in this bug report. |
Created attachment 1301969 [details] fixes gcc7 compiler warning Description of problem: compiling C programs which use PyMem_MALLOC in pymem.h throws [-Werror=int-in-bool-context] warning/error Version-Release number of selected component (if applicable): python2-2.7.13-12 (python2-devel-2.7.13-12) How reproducible: compile any C program using PyMem_MALLOC or PyMem_REALLOC macros Actual results: ... In file included from /usr/include/python2.7/Python.h:78:0, from netnsmodule.c:16: netnsmodule.c: In function 'netns_nsexecvp': /usr/include/python2.7/pymem.h:97:30: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context] ( (type *) PyMem_MALLOC((n) * sizeof(type)) ) ) ^ /usr/include/python2.7/pymem.h:75:15: note: in definition of macro 'PyMem_MALLOC' : malloc((n) ? (n) : 1)) ^ netnsmodule.c:61:10: note: in expansion of macro 'PyMem_NEW' argv = PyMem_NEW(char *, argc + 1); ^~~~~~~~~ cc1: all warnings being treated as errors error: command 'gcc' failed with exit status 1 ... Expected results: program (srpm) builds successfully Additional info: Proposed patch attached, makes gcc7 happy again! If this sounds reasonable, please also push upstream -- thanks!