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: Fix compiler warnings "comparison between signed and unsigned integers"
Type: compile error Stage: patch review
Components: Extension Modules, Interpreter Core Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: neologix, python-dev, serhiy.storchaka, vajrasky, vstinner
Priority: normal Keywords: patch

Created on 2014-08-06 10:38 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
fix_warnings.patch vstinner, 2014-08-06 10:38 review
Messages (11)
msg224924 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-08-06 10:38
The issue #22110 enabled more compiler warnings. Attached patch tries to fix most of them on Linux.
msg225013 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-08-07 14:33
Victor, your patch fixes most of the pesky warnings. However you left one warning left (at least in Mac OS X 10.9.4).

Objects/unicodeobject.c:4831:43: warning: comparison of integers of different signs: 'unsigned long' and 'long' [-Wsign-compare]
    if (PY_SSIZE_T_MAX /  sizeof(wchar_t) < (size + 1))
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~

Maybe we can fix it by doing this:
    if (PY_SSIZE_T_MAX / (Py_ssize_t)sizeof(wchar_t) < (size + 1))
        return NULL;
msg225020 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-08-07 16:01
> Victor, your patch fixes most of the pesky warnings. However you left one warning ...

Yes, my patch is uncomplete. Don't hesitate to post a new patch or
complete mine. I'm in holliday, I'm not going to update it before a
few weeks.
msg225366 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-08-15 21:34
New changeset 9b84ff16edd4 by Victor Stinner in branch 'default':
Issue #22156: Fix "comparison between signed and unsigned integers" compiler
http://hg.python.org/cpython/rev/9b84ff16edd4

New changeset a0b38f4eb79e by Victor Stinner in branch 'default':
Issue #22156: Fix "comparison between signed and unsigned integers" compiler
http://hg.python.org/cpython/rev/a0b38f4eb79e
msg225368 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-08-15 21:46
I created a specific issue for PyThread_create_key() of Python/thread_pthread.h: issue #22206.
msg225370 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-08-15 22:04
I created another more specific issue: #22207, "Test for integer overflow on Py_ssize_t: explicitly cast to size_t".
msg225371 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-08-15 23:12
New changeset e831a98b3f43 by Victor Stinner in branch 'default':
Issue #22156: Fix some "comparison between signed and unsigned integers"
http://hg.python.org/cpython/rev/e831a98b3f43
msg225373 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-08-15 23:15
Ok, I fixed many warnings in this issue. I will open new issues for other warnings.
msg225398 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-08-16 12:48
I'm not sure about _tracemalloc.c. May be make MAX_NFRAME an int would be simpler? Other changes LGTM.
msg225399 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-08-16 13:44
New changeset a318a5ab91fe by Victor Stinner in branch 'default':
Issue #22156: simplify _tracemalloc.c, use an int for the MAX_NFRAME constant
http://hg.python.org/cpython/rev/a318a5ab91fe
msg225400 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-08-16 13:45
> I'm not sure about _tracemalloc.c. May be make MAX_NFRAME an int would be simpler?

Ok, I agree, I changed it.
History
Date User Action Args
2022-04-11 14:58:06adminsetgithub: 66352
2014-08-16 13:45:05vstinnersetmessages: + msg225400
2014-08-16 13:44:13python-devsetmessages: + msg225399
2014-08-16 12:48:27serhiy.storchakasetmessages: + msg225398
2014-08-15 23:15:07vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg225373
2014-08-15 23:12:18python-devsetmessages: + msg225371
2014-08-15 23:11:37vstinnersettitle: Fix compiler warnings -> Fix compiler warnings "comparison between signed and unsigned integers"
2014-08-15 22:04:02vstinnersetmessages: + msg225370
2014-08-15 21:46:32vstinnersetmessages: + msg225368
2014-08-15 21:34:42python-devsetnosy: + python-dev
messages: + msg225366
2014-08-07 16:01:01vstinnersetmessages: + msg225020
2014-08-07 14:33:39vajraskysetnosy: + vajrasky
messages: + msg225013
2014-08-06 12:10:22serhiy.storchakasetnosy: + serhiy.storchaka

type: compile error
components: + Extension Modules, Interpreter Core
stage: patch review
2014-08-06 10:38:10vstinnercreate