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

Compilation Warning for memoryview.tobytes and _collections._tuplegetter.__reduce__ #80378

Closed
matrixise opened this issue Mar 5, 2019 · 7 comments
Assignees
Labels
3.8 only security fixes easy

Comments

@matrixise
Copy link
Member

BPO 36197
Nosy @vstinner, @serhiy-storchaka, @matrixise
PRs
  • bpo-33012: Fix compilation warnings for memoryview.tobytes and _collections._tuplegetter.__reduce__ #12179
  • Fix the C function signature for _collections._tuplegetter.__reduce__. #12180
  • Superseder
  • bpo-33012: Invalid function cast warnings with gcc 8 for METH_NOARGS
  • 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 = 'https://github.com/matrixise'
    closed_at = <Date 2019-03-05.14:57:52.535>
    created_at = <Date 2019-03-05.14:31:54.058>
    labels = ['easy', '3.8']
    title = 'Compilation Warning for memoryview.tobytes and _collections._tuplegetter.__reduce__'
    updated_at = <Date 2019-03-05.16:41:13.004>
    user = 'https://github.com/matrixise'

    bugs.python.org fields:

    activity = <Date 2019-03-05.16:41:13.004>
    actor = 'serhiy.storchaka'
    assignee = 'matrixise'
    closed = True
    closed_date = <Date 2019-03-05.14:57:52.535>
    closer = 'vstinner'
    components = []
    creation = <Date 2019-03-05.14:31:54.058>
    creator = 'matrixise'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 36197
    keywords = ['patch', 'easy (C)']
    message_count = 7.0
    messages = ['337191', '337195', '337196', '337208', '337211', '337212', '337226']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'serhiy.storchaka', 'matrixise']
    pr_nums = ['12179', '12180']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = '33012'
    type = None
    url = 'https://bugs.python.org/issue36197'
    versions = ['Python 3.8']

    @matrixise
    Copy link
    Member Author

    gcc -pthread -c -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -g -Og -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -I./Include/internal -I. -I./Include -DPy_BUILD_CORE -o Objects/memoryobject.o Objects/memoryobject.c
    Objects/memoryobject.c:3112:21: warning: cast between incompatible function types from 'PyObject * ()(PyMemoryViewObject *, PyObject *, PyObject *)' {aka 'struct _object * ()(struct <anonymous> *, struct _object *, struct _object *)'} to 'PyObject * ()(PyObject *, PyObject *)' {aka 'struct _object * ()(struct _object *, struct _object *)'} [-Wcast-function-type]
    {"tobytes", (PyCFunction)memory_tobytes, METH_VARARGS|METH_KEYWORDS, memory_tobytes_doc},

    I am preparing a small PR for this issue.

    @matrixise matrixise added the 3.8 only security fixes label Mar 5, 2019
    @matrixise matrixise self-assigned this Mar 5, 2019
    @matrixise matrixise added the easy label Mar 5, 2019
    @matrixise
    Copy link
    Member Author

    Fix an other warning in the same PR

    _collections._tuplegetter.__reduce__

    @matrixise matrixise changed the title Compilation Warning for memoryview.tobytes Compilation Warning for memoryview.tobytes and _collections._tuplegetter.__reduce__ Mar 5, 2019
    @vstinner
    Copy link
    Member

    vstinner commented Mar 5, 2019

    I prefer to reuse bpo-33012.

    @vstinner vstinner closed this as completed Mar 5, 2019
    @serhiy-storchaka
    Copy link
    Member

    This is not correct fix for tuplegetter_reduce. tuplegetter_reduce should have two parameters, just the second is unused.

    @matrixise
    Copy link
    Member Author

    Hi @serhiy,

    Thank you for your PR, I prefer your patch, just because you have just added the PyObject *Py_UNUSED(ignored) to the tuplegetter_reduce function. And in this case, you don't need to cast to (void(*)(void)).

    I will use this tip for the next time.

    Thank

    @serhiy-storchaka
    Copy link
    Member

    This is only for methods with METH_NOARGS. The code that calls such method, calls it with two arguments, passing NULL as the second argument. So the signature of the C function should have two parameters. Functions for methods with METH_KEYWORDS or METH_FASTCALL should have different corresponding signatures.

    @serhiy-storchaka
    Copy link
    Member

    New changeset adfffc7 by Serhiy Storchaka in branch 'master':
    Fix the C function signature for _collections._tuplegetter.__reduce__. (GH-12180)
    adfffc7

    @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
    3.8 only security fixes easy
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants