Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiler warnings "comparison between signed and unsigned integers" #66352

Closed
vstinner opened this issue Aug 6, 2014 · 11 comments
Closed
Labels
build The build process and cross-build extension-modules C modules in the Modules dir interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@vstinner
Copy link
Member

vstinner commented Aug 6, 2014

BPO 22156
Nosy @vstinner, @serhiy-storchaka, @vajrasky
Files
  • fix_warnings.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2014-08-15.23:15:07.434>
    created_at = <Date 2014-08-06.10:38:10.945>
    labels = ['extension-modules', 'interpreter-core', 'build']
    title = 'Fix compiler warnings "comparison between signed and unsigned integers"'
    updated_at = <Date 2014-08-16.13:45:05.650>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2014-08-16.13:45:05.650>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2014-08-15.23:15:07.434>
    closer = 'vstinner'
    components = ['Extension Modules', 'Interpreter Core']
    creation = <Date 2014-08-06.10:38:10.945>
    creator = 'vstinner'
    dependencies = []
    files = ['36287']
    hgrepos = []
    issue_num = 22156
    keywords = ['patch']
    message_count = 11.0
    messages = ['224924', '225013', '225020', '225366', '225368', '225370', '225371', '225373', '225398', '225399', '225400']
    nosy_count = 5.0
    nosy_names = ['vstinner', 'neologix', 'python-dev', 'serhiy.storchaka', 'vajrasky']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'patch review'
    status = 'closed'
    superseder = None
    type = 'compile error'
    url = 'https://bugs.python.org/issue22156'
    versions = ['Python 3.5']

    @vstinner
    Copy link
    Member Author

    vstinner commented Aug 6, 2014

    The issue bpo-22110 enabled more compiler warnings. Attached patch tries to fix most of them on Linux.

    @serhiy-storchaka serhiy-storchaka added extension-modules C modules in the Modules dir interpreter-core (Objects, Python, Grammar, and Parser dirs) build The build process and cross-build labels Aug 6, 2014
    @vajrasky
    Copy link
    Mannequin

    vajrasky mannequin commented Aug 7, 2014

    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;

    @vstinner
    Copy link
    Member Author

    vstinner commented Aug 7, 2014

    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.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Aug 15, 2014

    New changeset 9b84ff16edd4 by Victor Stinner in branch 'default':
    Issue bpo-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 bpo-22156: Fix "comparison between signed and unsigned integers" compiler
    http://hg.python.org/cpython/rev/a0b38f4eb79e

    @vstinner
    Copy link
    Member Author

    I created a specific issue for PyThread_create_key() of Python/thread_pthread.h: issue bpo-22206.

    @vstinner
    Copy link
    Member Author

    I created another more specific issue: bpo-22207, "Test for integer overflow on Py_ssize_t: explicitly cast to size_t".

    @vstinner vstinner changed the title Fix compiler warnings Fix compiler warnings "comparison between signed and unsigned integers" Aug 15, 2014
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Aug 15, 2014

    New changeset e831a98b3f43 by Victor Stinner in branch 'default':
    Issue bpo-22156: Fix some "comparison between signed and unsigned integers"
    http://hg.python.org/cpython/rev/e831a98b3f43

    @vstinner
    Copy link
    Member Author

    Ok, I fixed many warnings in this issue. I will open new issues for other warnings.

    @serhiy-storchaka
    Copy link
    Member

    I'm not sure about _tracemalloc.c. May be make MAX_NFRAME an int would be simpler? Other changes LGTM.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Aug 16, 2014

    New changeset a318a5ab91fe by Victor Stinner in branch 'default':
    Issue bpo-22156: simplify _tracemalloc.c, use an int for the MAX_NFRAME constant
    http://hg.python.org/cpython/rev/a318a5ab91fe

    @vstinner
    Copy link
    Member Author

    I'm not sure about _tracemalloc.c. May be make MAX_NFRAME an int would be simpler?

    Ok, I agree, I changed it.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    build The build process and cross-build extension-modules C modules in the Modules dir interpreter-core (Objects, Python, Grammar, and Parser dirs)
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants