This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: implicit-int-float-conversion warnings in time and math code
Type: compile error Stage:
Components: Versions: Python 3.10, Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, mark.dickinson, p-ganssle, vstinner
Priority: normal Keywords:

Created on 2020-06-17 07:16 by christian.heimes, last changed 2022-04-11 14:59 by admin.

Messages (2)
msg371714 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2020-06-17 07:16
clang 10 with asan and ubsan complains about implicit int to float conversion in time and math related code:

$ CC=clang ./configure --with-address-sanitizer --with-undefined-behavior-sanitizer
$ make clean
$ make -s
Python/pytime.c:154:10: warning: implicit conversion from 'long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-int-float-conversion]
    if (!_Py_InIntegralTypeRange(time_t, intpart)) {
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./Include/pymath.h:228:82: note: expanded from macro '_Py_InIntegralTypeRange'
#define _Py_InIntegralTypeRange(type, v) (_Py_IntegralTypeMin(type) <= v && v <= _Py_IntegralTypeMax(type))
                                                                              ~~ ^~~~~~~~~~~~~~~~~~~~~~~~~
./Include/pymath.h:221:124: note: expanded from macro '_Py_IntegralTypeMax'
#define _Py_IntegralTypeMax(type) ((_Py_IntegralTypeSigned(type)) ? (((((type)1 << (sizeof(type)*CHAR_BIT - 2)) - 1) << 1) + 1) : ~(type)0)
                                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
Python/pytime.c:207:14: warning: implicit conversion from 'long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-int-float-conversion]
        if (!_Py_InIntegralTypeRange(time_t, intpart)) {
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./Include/pymath.h:228:82: note: expanded from macro '_Py_InIntegralTypeRange'
#define _Py_InIntegralTypeRange(type, v) (_Py_IntegralTypeMin(type) <= v && v <= _Py_IntegralTypeMax(type))
                                                                              ~~ ^~~~~~~~~~~~~~~~~~~~~~~~~
./Include/pymath.h:221:124: note: expanded from macro '_Py_IntegralTypeMax'
#define _Py_IntegralTypeMax(type) ((_Py_IntegralTypeSigned(type)) ? (((((type)1 << (sizeof(type)*CHAR_BIT - 2)) - 1) << 1) + 1) : ~(type)0)
                                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
Python/pytime.c:392:10: warning: implicit conversion from 'long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-int-float-conversion]
    if (!_Py_InIntegralTypeRange(_PyTime_t, d)) {
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./Include/pymath.h:228:82: note: expanded from macro '_Py_InIntegralTypeRange'
#define _Py_InIntegralTypeRange(type, v) (_Py_IntegralTypeMin(type) <= v && v <= _Py_IntegralTypeMax(type))
                                                                              ~~ ^~~~~~~~~~~~~~~~~~~~~~~~~
./Include/pymath.h:221:124: note: expanded from macro '_Py_IntegralTypeMax'
#define _Py_IntegralTypeMax(type) ((_Py_IntegralTypeSigned(type)) ? (((((type)1 << (sizeof(type)*CHAR_BIT - 2)) - 1) << 1) + 1) : ~(type)0)
                                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
3 warnings generated.
./Modules/timemodule.c:116:13: warning: code will never be executed [-Wunreachable-code]
            PyErr_SetString(PyExc_OverflowError,
            ^~~~~~~~~~~~~~~
1 warning generated.
./Modules/_threadmodule.c:1587:19: warning: implicit conversion from '_PyTime_t' (aka 'long') to 'double' changes value from 9223372036854775 to 9223372036854776 [-Wimplicit-int-float-conversion]
    timeout_max = (_PyTime_t)PY_TIMEOUT_MAX * 1e-6;
                  ^~~~~~~~~~~~~~~~~~~~~~~~~ ~
1 warning generated.
msg371762 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2020-06-17 16:56
I think #39277 is related.
History
Date User Action Args
2022-04-11 14:59:32adminsetgithub: 85171
2020-06-17 16:56:12mark.dickinsonsetnosy: + vstinner
messages: + msg371762
2020-06-17 07:16:15christian.heimescreate