Skip to content

New warning: ‘value’ may be used uninitialized in this function [-Wmaybe-uninitialized] #105673

Closed

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    testsTests in the Lib/test dir
    interpreter-core(Objects, Python, Grammar, and Parser dirs)
    on Jun 12, 2023
  2. self-assigned this
    on Jun 12, 2023
  3. added a commit that references this issue on Jun 12, 2023
  4. sobolevn commented on Jun 12, 2023

    @sobolevn
    MemberAuthor

    Better output (greppable and more precise):

                    -o Python/sysmodule.o ./Python/sysmodule.c
    ./Python/sysmodule.c:3390:13: warning: variable 'value' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
            if (name == NULL) {
                ^~~~~~~~~~~~
    ./Python/sysmodule.c:3407:16: note: uninitialized use occurs here
        Py_XDECREF(value);
                   ^~~~~
    ./Include/object.h:792:52: note: expanded from macro 'Py_XDECREF'
    #  define Py_XDECREF(op) Py_XDECREF(_PyObject_CAST(op))
                                                       ^~
    ./Include/object.h:178:49: note: expanded from macro '_PyObject_CAST'
    #define _PyObject_CAST(op) _Py_CAST(PyObject*, (op))
                                                    ^~
    ./Include/pyport.h:24:38: note: expanded from macro '_Py_CAST'
    #define _Py_CAST(type, expr) ((type)(expr))
                                         ^~~~
    ./Python/sysmodule.c:3390:9: note: remove the 'if' if its condition is always false
            if (name == NULL) {
            ^~~~~~~~~~~~~~~~~~~
    ./Python/sysmodule.c:3383:13: warning: variable 'value' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
            if (name == NULL) {
                ^~~~~~~~~~~~
    ./Python/sysmodule.c:3407:16: note: uninitialized use occurs here
        Py_XDECREF(value);
                   ^~~~~
    ./Include/object.h:792:52: note: expanded from macro 'Py_XDECREF'
    #  define Py_XDECREF(op) Py_XDECREF(_PyObject_CAST(op))
                                                       ^~
    ./Include/object.h:178:49: note: expanded from macro '_PyObject_CAST'
    #define _PyObject_CAST(op) _Py_CAST(PyObject*, (op))
                                                    ^~
    ./Include/pyport.h:24:38: note: expanded from macro '_Py_CAST'
    #define _Py_CAST(type, expr) ((type)(expr))
                                         ^~~~
    ./Python/sysmodule.c:3383:9: note: remove the 'if' if its condition is always false
            if (name == NULL) {
            ^~~~~~~~~~~~~~~~~~~
    ./Python/sysmodule.c:3378:27: note: initialize the variable 'value' to silence this warning
        PyObject *name, *value;
                              ^
                               = NULL
    
  5. added a commit that references this issue on Jun 12, 2023
  6. added 2 commits that reference this issue on Jun 12, 2023
  7. added 2 commits that reference this issue on Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions