[New-bugs-announce] [issue28118] type-limits warning in PyMem_New() _ssl_locks_count

Christian Heimes report at bugs.python.org
Tue Sep 13 03:23:20 EDT 2016

New submission from Christian Heimes:

Since last week I'm getting a compiler warning in _ssl.c. The compiler warning is related to the type of _ssl_locks_count. It's an unsigned. When I cast it to an int like PyMem_New(PyThread_type_lock, (int)_ssl_locks_count), the warning goes away.

gcc -pthread -fPIC -Wno-unused-result -Wsign-compare -g -Og -Wall -Wstrict-prototypes -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -I./Include -I. -IInclude -I/usr/local/include -I/home/heimes/dev/python/3.6/Include -I/home/heimes/dev/python/3.6 -c /home/heimes/dev/python/3.6/Modules/_ssl.c -o build/temp.linux-x86_64-3.6-pydebug/home/heimes/dev/python/3.6/Modules/_ssl.o
In file included from ./Include/Python.h:66:0,
                 from /home/heimes/dev/python/3.6/Modules/_ssl.c:19:
/home/heimes/dev/python/3.6/Modules/_ssl.c: In function ‘_setup_ssl_threads’:
./Include/pymem.h:136:18: warning: comparison is always false due to limited range of data type [-Wtype-limits]
   ( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
/home/heimes/dev/python/3.6/Modules/_ssl.c:5076:22: note: in expansion of macro ‘PyMem_New’
         _ssl_locks = PyMem_New(PyThread_type_lock, _ssl_locks_count);

Also see #17884

components: Extension Modules
messages: 276195
nosy: christian.heimes, haypo
priority: normal
severity: normal
stage: needs patch
status: open
type: compile error
versions: Python 3.6, Python 3.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list