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

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

Closed
sobolevn opened this issue Jun 12, 2023 · 1 comment
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member

sobolevn commented Jun 12, 2023

@sobolevn sobolevn added type-bug An unexpected behavior, bug, or error tests Tests in the Lib/test dir interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Jun 12, 2023
@sobolevn sobolevn self-assigned this Jun 12, 2023
sobolevn added a commit to sobolevn/cpython that referenced this issue Jun 12, 2023
@sobolevn
Copy link
Member Author

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

erlend-aasland pushed a commit that referenced this issue Jun 12, 2023
In sys_add_xoption(), 'value' may be uninitialized for some error paths.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 12, 2023
…05674)

In sys_add_xoption(), 'value' may be uninitialized for some error paths.
(cherry picked from commit a8d69fe)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 12, 2023
…05674)

In sys_add_xoption(), 'value' may be uninitialized for some error paths.
(cherry picked from commit a8d69fe)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
erlend-aasland pushed a commit that referenced this issue Jun 12, 2023
#105676)

In sys_add_xoption(), 'value' may be uninitialized for some error paths.
(cherry picked from commit a8d69fe)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
erlend-aasland pushed a commit that referenced this issue Jun 12, 2023
#105675)

In sys_add_xoption(), 'value' may be uninitialized for some error paths.
(cherry picked from commit a8d69fe)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants