classification
Title: Warnings when building on AIX
Type: compile error Stage: resolved
Components: Build Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: David.Edelsohn, jelie, martin.panter, python-dev
Priority: normal Keywords:

Created on 2014-09-22 17:32 by jelie, last changed 2016-06-22 03:14 by martin.panter. This issue is now closed.

Messages (8)
msg227283 - (view) Author: Julien ÉLIE (jelie) Date: 2014-09-22 17:32
Building Python 2.7.8 on AIX 7.1 gives the following warnings:

Parser/pgen.c:282:9: warning: variable 'i' set but not used [-Wunused-but-set-variable]
Include/objimpl.h:164:66: warning: right-hand operand of comma expression has no effect [-Wunused-value]
/home/iulius/autobuild/src/Python-2.7.8/Modules/cPickle.c:4495:8: warning: assuming signed overflow does not occur when assuming that (X - c) > X is always false [-Wstrict-overflow]
/home/iulius/autobuild/src/Python-2.7.8/Modules/cPickle.c:202:8: warning: assuming signed overflow does not occur when assuming that (X - c) > X is always false [-Wstrict-overflow]
/home/iulius/autobuild/src/Python-2.7.8/Modules/readline.c:777:1: warning: 'on_completion_display_matches_hook' defined but not used [-Wunused-function]
./pyconfig.h:1182:0: warning: "_POSIX_C_SOURCE" redefined
./pyconfig.h:1204:0: warning: "_XOPEN_SOURCE" redefined
/home/iulius/autobuild/src/Python-2.7.8/Modules/tkappinit.c:29:15: warning: variable 'main_window' set but not used [-Wunused-but-set-variable]
/home/iulius/autobuild/src/Python-2.7.8/Modules/_ctypes/ctypes.h:456:13: warning: 'capsule_destructor_CTYPES_CAPSULE_WCHAR_T' defined but not used [-Wunused-function]
/home/iulius/autobuild/src/Python-2.7.8/Modules/_ctypes/cfield.c:50:29: warning: variable 'length' set but not used [-Wunused-but-set-variable]
/home/iulius/autobuild/src/Python-2.7.8/Modules/_ctypes/ctypes.h:456:13: warning: 'capsule_destructor_CTYPES_CAPSULE_WCHAR_T' defined but not used [-Wunused-function]
msg268982 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-06-21 10:50
The most serious of these IMO is the signed overflow warnings in Modules/cPickle.c. I get the same warnings if I disable the “gcc -fwrapv” mode:

/media/disk/home/proj/python/cpython/Modules/cPickle.c: In function ‘Unpickler_noload’:
/media/disk/home/proj/python/cpython/Modules/cPickle.c:5462:1: warning: assuming signed overflow does not occur when assuming that (X - c) > X is always false [-Wstrict-overflow]
 Unpickler_noload(Unpicklerobject *self, PyObject *unused)
 ^
/media/disk/home/proj/python/cpython/Modules/cPickle.c:5462:1: warning: assuming signed overflow does not occur when assuming that (X - c) > X is always false [-Wstrict-overflow]
/media/disk/home/proj/python/cpython/Modules/cPickle.c:202:8: warning: assuming signed overflow does not occur when assuming that (X - c) > X is always false [-Wstrict-overflow]
     if (clearto >= self->length) return 0;
        ^
/media/disk/home/proj/python/cpython/Modules/cPickle.c:202:8: warning: assuming signed overflow does not occur when assuming that (X - c) > X is always false [-Wstrict-overflow]
     if (clearto >= self->length) return 0;
        ^

It is not clear to me where the overflows actually happen. See Issue 1608, Issue 1621, where some of these bugs were fixed, and the “gcc -fwrapv” workaround was enabled. Perhaps your compiler has a similar flag to use as a workaround, though IMO it would be good to fix the code as well.

Most of the other warnings have been fixed or worked around in Python 3. I propose to port the following revisions to Python 2. All but one are still in effect today:

83a55ca935f0: Parser/pgen.c
12e53abec5d0, 0c7fff783b32: Include/objimpl.h
ce9f5ce33ad2: Modules/readline.c
a7a9e0f46b8a: Modules/tkappinit.c (change present in 3.3, 3.4, but eliminated in 3.5)
e2f96bd29252 (partial): Modules/_ctypes/cfield.c
b04557ae099a (partial): Modules/expat/xmlparse.c (assuming this was the cause of the ./pyconfig.h warnings)

That leaves the two warnings about CTYPES_CAPSULE_WCHAR_T. If necessary, they could be worked around by adding an #if condition around the definitions:

#if defined(CTYPES_UNICODE) && !defined(HAVE_USABLE_WCHAR_T)
#    define CTYPES_CAPSULE_WCHAR_T "_ctypes/[. . .].c wchar_t buffer from unicode"
CTYPES_CAPSULE_INSTANTIATE_DESTRUCTOR(CTYPES_CAPSULE_WCHAR_T)
#endif
msg268984 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-06-21 11:38
Looking closer at cPickle.c (after upgrading my GCC), I think there are two warnings happening, when Pdata_clear() is inlined into each of noload_reduce() and noload_setitem(). I think both cases are false positives; there is no actual signed overflow possible. Ismail Donmez has provided patches that work around this warning in Issue 1621, but IMO, and maybe in the general consensus, we shouldn’t add these workarounds.
msg268996 - (view) Author: David Edelsohn (David.Edelsohn) * Date: 2016-06-21 13:38
These look like false positives or noise to me as well.
msg269037 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-06-22 00:49
New changeset 0b63465a1796 by Martin Panter in branch '2.7':
Issue #22463: Backport compiler warning fixes and workarounds
https://hg.python.org/cpython/rev/0b63465a1796
msg269039 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-06-22 02:09
New changeset b1c1c297bead by Martin Panter in branch '2.7':
Issue #22463: Correct #endif placement; patch by Senthil Kumaran
https://hg.python.org/cpython/rev/b1c1c297bead
msg269040 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-06-22 02:50
New changeset ffe866aa86a8 by Martin Panter in branch '2.7':
Issue #22463: Cure unused function warnings on AIX
https://hg.python.org/cpython/rev/ffe866aa86a8
msg269043 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-06-22 03:14
FWIW on the current AIX buildbot <http://buildbot.python.org/all/builders/PPC64%20AIX%202.7> I don’t see any cPickle.c warnings. (Nor on the earliest build available on that buildbot, from Nov 2015.)
History
Date User Action Args
2016-06-22 03:14:27martin.pantersetstatus: open -> closed
resolution: fixed
messages: + msg269043

stage: resolved
2016-06-22 02:50:00python-devsetmessages: + msg269040
2016-06-22 02:09:26python-devsetmessages: + msg269039
2016-06-22 00:49:29python-devsetnosy: + python-dev
messages: + msg269037
2016-06-21 13:38:39David.Edelsohnsetmessages: + msg268996
2016-06-21 11:38:06martin.pantersetmessages: + msg268984
2016-06-21 10:50:57martin.pantersetnosy: + martin.panter
messages: + msg268982
2014-09-22 18:57:10David.Edelsohnsetnosy: + David.Edelsohn
2014-09-22 17:32:49jeliecreate