classification
Title: Warning about a potential dead code in timemodule and Clang
Type: Stage:
Components: Interpreter Core Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: matrixise, p-ganssle
Priority: normal Keywords:

Created on 2019-03-17 19:20 by matrixise, last changed 2019-03-17 22:29 by matrixise.

Messages (4)
msg338137 - (view) Author: St├ęphane Wirtel (matrixise) * (Python committer) Date: 2019-03-17 19:20
env CC="/usr/bin/clang" CCX="/usr/bin/clang" ./configure > /dev/null ;and make -j 4 > /dev/null

./Modules/timemodule.c:113:13: warning: code will never be executed [-Wunreachable-code]
            PyErr_SetString(PyExc_OverflowError,
            ^~~~~~~~~~~~~~~
1 warning generated.
msg338138 - (view) Author: Paul Ganssle (p-ganssle) * (Python committer) Date: 2019-03-17 19:55
It does seem like the values CLOCKS_PER_SEC, _PyTime_MAX and SEC_TO_NS are all defined at compile-time, so presumably this can be a compile-time error.

As currently defined, though, it seems very unlikely that this would ever be false, since _PyTime_MAX is the same as LLONG_MAX, which cplusplusreference says is `9223372036854775807 (2**63-1) or greater` [0], so CLOCKS_PER_SEC would need to be >= 2**50, which is unlikely to be... accurate.

In any case, it seems like this check can happen at compile-time, either resulting in compilation failing, or just undefining HAVE_CLOCK.

[0] http://www.cplusplus.com/reference/climits/
msg338139 - (view) Author: Paul Ganssle (p-ganssle) * (Python committer) Date: 2019-03-17 19:58
Sorry, I should say unlikely that it should ever be *true*. It seems unlikely that there is a platform or piece of hardware on which this error would be raised.
msg338144 - (view) Author: St├ęphane Wirtel (matrixise) * (Python committer) Date: 2019-03-17 22:29
Hi Paul,

Thank you for your explanation, I was not sure about the solution and I have just preferred to publish this issue. I don't have this issue with gcc, only with clang.
History
Date User Action Args
2019-03-17 22:29:54matrixisesetmessages: + msg338144
2019-03-17 19:58:24p-gansslesetmessages: + msg338139
2019-03-17 19:55:56p-gansslesetnosy: + p-ganssle
messages: + msg338138
2019-03-17 19:20:11matrixisecreate