Message412670
PY_SSIZE_T_MAX is currently defined in Include/pyport.h as:
#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1))
This is not an integer constant expression, which means it can't be used in preprocessor conditionals. For example:
#if PY_SSIZE_T_MAX > UINT32_MAX
will fail to compile. This was touched upon and ignored a long time ago:
https://mail.python.org/archives/list/python-dev@python.org/thread/27X7LINL4UO7DAJE6J3IFQEZGUKAO4VL/
I think the best fix is to move the definition of PY_SSIZE_T_MAX (and PY_SSIZE_T_MIN) next to the definition of Py_ssize_t, and use the proper corresponding limit macro. If Py_ssize_t is a typedef for ssize_t, then PY_SSIZE_T_MAX should be SSIZE_MAX. If Py_ssize_t is a typedef for Py_intptr_t, then PY_SSIZE_T_MAX should be INTPTR_MAX. There's a minor complication because Py_ssize_t can be defined in PC/pyconfig.h. I'm not so familiar with the various Windows compilers, so I'm not sure what's best to do here. I think __int64 has a corresponding _I64_MAX macro, and int obviously has INT_MAX. |
|
Date |
User |
Action |
Args |
2022-02-06 21:20:42 | ov2k | set | recipients:
+ ov2k |
2022-02-06 21:20:42 | ov2k | set | messageid: <1644182442.72.0.928372209775.issue46664@roundup.psfhosted.org> |
2022-02-06 21:20:42 | ov2k | link | issue46664 messages |
2022-02-06 21:20:42 | ov2k | create | |
|