classification
Title: -Wstrict-overflow findings
Type: compile error Stage: resolved
Components: Build Versions: Python 3.7, Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: Jeffrey.Walton, christian.heimes, martin.panter, python-dev, serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2014-03-16 17:39 by Jeffrey.Walton, last changed 2016-09-27 19:05 by serhiy.storchaka. This issue is now closed.

Files
File name Uploaded Description Edit
issue20947.patch serhiy.storchaka, 2016-09-25 14:34 review
Repositories containing patches
http://hg.python.org/cpython
Messages (7)
msg213742 - (view) Author: Jeffrey Walton (Jeffrey.Walton) * Date: 2014-03-16 17:39
$ hg id
3736bf94535c+ tip

Forgive me if you were aware of these. 

/usr/bin/gcc -pthread -fPIC -Wno-unused-result -Werror=declaration-after-statement -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fno-common -Wstrict-overflow -Wformat=2 -Wformat-security -Wcast-align -Wtrampolines -fno-common -Wstrict-overflow -Wformat=2 -Wformat-security -Wcast-align -Wtrampolines -I./Include -I. -IInclude -I/usr/include/x86_64-linux-gnu -I/usr/local/include -Icpython/./Include -Icpython/. -c cpython/./Modules/_posixsubprocess.c -o build/temp.linux-x86_64-3.4cpython/./Modules/_posixsubprocess.o
cpython/./Modules/_posixsubprocess.c: In function ‘child_exec’:
cpython/./Modules/_posixsubprocess.c:491:33: warning: assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2 [-Wstrict-overflow]
cpython/./Modules/_posixsubprocess.c: In function ‘subprocess_fork_exec’:
cpython/./Modules/_posixsubprocess.c:491:33: warning: assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2 [-Wstrict-overflow]
cpython/./Modules/_posixsubprocess.c:491:33: warning: assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2 [-Wstrict-overflow]
cpython/./Modules/_posixsubprocess.c:491:33: warning: assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2 [-Wstrict-overflow]
...

/usr/bin/gcc -pthread -fPIC -Wno-unused-result -Werror=declaration-after-statement -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fno-common -Wstrict-overflow -Wformat=2 -Wformat-security -Wcast-align -Wtrampolines -fno-common -Wstrict-overflow -Wformat=2 -Wformat-security -Wcast-align -Wtrampolines -I./Include -I. -IInclude -I/usr/include/x86_64-linux-gnu -I/usr/local/include -Icpython/./Include -Icpython/. -c cpython/./Modules/sha512module.c -o build/temp.linux-x86_64-3.4cpython/./Modules/sha512module.o
cpython/./Modules/sha512module.c: In function ‘sha512_transform’:
cpython/./Modules/sha512module.c:128:1: warning: assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2 [-Wstrict-overflow]
cpython/./Modules/sha512module.c:128:1: warning: assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2 [-Wstrict-overflow]
msg235817 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2015-02-12 12:18
@Serhiy/Victor I believe that you're both interested in this type of problem.
msg271508 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-07-28 08:07
Regarding the warning in Modules/_posixsubprocess.c, I don’t see any problem. I’m not sure exactly what it is warning about. Maybe if the cur pointer ever gets _before_ the start of hex_errno, that could be a problem, but the loop should stop when it reaches the start.

The warnings in Modules/sha512module.c refer to the first line of the sha512_transform() function. I cannot see any pointer comparisons in that function. The closest is pointer and array indexing, but it all seems to be in order.

I propose to ignore these warnings.
msg277375 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2016-09-25 13:18
I can no longer reproduce the warnings with

$ CFLAGS=-Wstrict-overflow ./configure -C --with-pydebug --silent
$ make --silent
msg277378 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-09-25 14:34
I can reproduce warnings in Modules/_posixsubprocess.c:

gcc -pthread -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-overflow -I./Include -I. -I/usr/include/i386-linux-gnu -I/usr/local/include -I/home/serhiy/py/cpython/Include -I/home/serhiy/py/cpython -c /home/serhiy/py/cpython/Modules/_posixsubprocess.c -o build/temp.linux-i686-3.7/home/serhiy/py/cpython/Modules/_posixsubprocess.o
/home/serhiy/py/cpython/Modules/_posixsubprocess.c: In function ‘child_exec’:
/home/serhiy/py/cpython/Modules/_posixsubprocess.c:524:33: warning: assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2 [-Wstrict-overflow]
         while (saved_errno != 0 && cur > hex_errno) {
                                 ^
/home/serhiy/py/cpython/Modules/_posixsubprocess.c: In function ‘subprocess_fork_exec’:
/home/serhiy/py/cpython/Modules/_posixsubprocess.c:524:33: warning: assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2 [-Wstrict-overflow]
         while (saved_errno != 0 && cur > hex_errno) {
                                 ^
/home/serhiy/py/cpython/Modules/_posixsubprocess.c:544:1: warning: assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2 [-Wstrict-overflow]
 subprocess_fork_exec(PyObject* self, PyObject *args)
 ^
/home/serhiy/py/cpython/Modules/_posixsubprocess.c:544:1: warning: assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2 [-Wstrict-overflow]
/home/serhiy/py/cpython/Modules/_posixsubprocess.c:524:33: warning: assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2 [-Wstrict-overflow]
         while (saved_errno != 0 && cur > hex_errno) {
                                 ^
/home/serhiy/py/cpython/Modules/_posixsubprocess.c:524:33: warning: assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2 [-Wstrict-overflow]

Proposed simple patch fixes this.
msg277379 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-09-25 14:35
Use following command for reproducing:

    make -s CFLAGS=-Wstrict-overflow
msg277540 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-09-27 19:05
New changeset dad879edefd2 by Serhiy Storchaka in branch '3.5':
Issue #20947: Fixed a gcc warning with -Wstrict-overflow.
https://hg.python.org/cpython/rev/dad879edefd2

New changeset 5ecbe8a55ccd by Serhiy Storchaka in branch '3.6':
Issue #20947: Fixed a gcc warning with -Wstrict-overflow.
https://hg.python.org/cpython/rev/5ecbe8a55ccd

New changeset 675d3f76444d by Serhiy Storchaka in branch 'default':
Issue #20947: Fixed a gcc warning with -Wstrict-overflow.
https://hg.python.org/cpython/rev/675d3f76444d
History
Date User Action Args
2016-09-27 19:05:44serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2016-09-27 19:05:27python-devsetnosy: + python-dev
messages: + msg277540
2016-09-25 14:35:50serhiy.storchakasetmessages: + msg277379
2016-09-25 14:34:11serhiy.storchakasetstatus: closed -> open
files: + issue20947.patch

assignee: serhiy.storchaka
versions: + Python 3.6, Python 3.7
keywords: + patch
resolution: wont fix -> (no value)
messages: + msg277378
stage: resolved -> patch review
2016-09-25 13:18:13christian.heimessetstatus: open -> closed

nosy: + christian.heimes
messages: + msg277375

stage: resolved
2016-07-28 08:30:11BreamoreBoysetnosy: - BreamoreBoy
2016-07-28 08:07:51martin.pantersetnosy: + martin.panter
messages: + msg271508
resolution: wont fix

type: compile error
2015-02-12 12:18:27BreamoreBoysetnosy: + BreamoreBoy, vstinner, serhiy.storchaka
messages: + msg235817
2014-03-16 17:39:57Jeffrey.Waltoncreate