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: Argument Clinic causing compiler warnings about uninitialized variables
Type: Stage: resolved
Components: Extension Modules Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: larry Nosy List: brett.cannon, larry, python-dev
Priority: normal Keywords:

Created on 2013-11-01 14:32 by brett.cannon, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg201901 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2013-11-01 14:32
In the curses module there are some variables that can go uninitialized which are causing clang to complain:

/Users/bcannon/Repositories/cpython/default/Modules/_cursesmodule.c:624:17: warning: variable
      'x' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
            if (!PyArg_ParseTuple(args, "Ol:addch", &ch, &attr))
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bcannon/Repositories/cpython/default/Modules/_cursesmodule.c:643:65: note: 
      uninitialized use occurs here
    return_value = curses_window_addch_impl(self, group_left_1, x, y, ch, group_right_1, attr);
                                                                ^
/Users/bcannon/Repositories/cpython/default/Modules/_cursesmodule.c:624:13: note: remove the
      'if' if its condition is always true
            if (!PyArg_ParseTuple(args, "Ol:addch", &ch, &attr))
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bcannon/Repositories/cpython/default/Modules/_cursesmodule.c:620:17: warning: variable
      'x' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
            if (!PyArg_ParseTuple(args, "O:addch", &ch))
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bcannon/Repositories/cpython/default/Modules/_cursesmodule.c:643:65: note: 
      uninitialized use occurs here
    return_value = curses_window_addch_impl(self, group_left_1, x, y, ch, group_right_1, attr);
                                                                ^
/Users/bcannon/Repositories/cpython/default/Modules/_cursesmodule.c:620:13: note: remove the
      'if' if its condition is always true
            if (!PyArg_ParseTuple(args, "O:addch", &ch))
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bcannon/Repositories/cpython/default/Modules/_cursesmodule.c:612:10: note: initialize
      the variable 'x' to silence this warning
    int x;
         ^
          = 0
/Users/bcannon/Repositories/cpython/default/Modules/_cursesmodule.c:624:17: warning: variable
      'y' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
            if (!PyArg_ParseTuple(args, "Ol:addch", &ch, &attr))
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bcannon/Repositories/cpython/default/Modules/_cursesmodule.c:643:68: note: 
      uninitialized use occurs here
    return_value = curses_window_addch_impl(self, group_left_1, x, y, ch, group_right_1, attr);
                                                                   ^
/Users/bcannon/Repositories/cpython/default/Modules/_cursesmodule.c:624:13: note: remove the
      'if' if its condition is always true
            if (!PyArg_ParseTuple(args, "Ol:addch", &ch, &attr))
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bcannon/Repositories/cpython/default/Modules/_cursesmodule.c:620:17: warning: variable
      'y' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
            if (!PyArg_ParseTuple(args, "O:addch", &ch))
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bcannon/Repositories/cpython/default/Modules/_cursesmodule.c:643:68: note: 
      uninitialized use occurs here
    return_value = curses_window_addch_impl(self, group_left_1, x, y, ch, group_right_1, attr);
                                                                   ^
/Users/bcannon/Repositories/cpython/default/Modules/_cursesmodule.c:620:13: note: remove the
      'if' if its condition is always true
            if (!PyArg_ParseTuple(args, "O:addch", &ch))
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bcannon/Repositories/cpython/default/Modules/_cursesmodule.c:613:10: note: initialize
      the variable 'y' to silence this warning
    int y;
         ^
          = 0
/Users/bcannon/Repositories/cpython/default/Modules/_cursesmodule.c:629:17: warning: variable
      'attr' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
            if (!PyArg_ParseTuple(args, "iiO:addch", &x, &y, &ch))
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bcannon/Repositories/cpython/default/Modules/_cursesmodule.c:643:90: note: 
      uninitialized use occurs here
    return_value = curses_window_addch_impl(self, group_left_1, x, y, ch, group_right_1, attr);
                                                                                         ^~~~
/Users/bcannon/Repositories/cpython/default/Modules/_cursesmodule.c:629:13: note: remove the
      'if' if its condition is always true
            if (!PyArg_ParseTuple(args, "iiO:addch", &x, &y, &ch))
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bcannon/Repositories/cpython/default/Modules/_cursesmodule.c:620:17: warning: variable
      'attr' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
            if (!PyArg_ParseTuple(args, "O:addch", &ch))
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bcannon/Repositories/cpython/default/Modules/_cursesmodule.c:643:90: note: 
      uninitialized use occurs here
    return_value = curses_window_addch_impl(self, group_left_1, x, y, ch, group_right_1, attr);
                                                                                         ^~~~
/Users/bcannon/Repositories/cpython/default/Modules/_cursesmodule.c:620:13: note: remove the
      'if' if its condition is always true
            if (!PyArg_ParseTuple(args, "O:addch", &ch))
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bcannon/Repositories/cpython/default/Modules/_cursesmodule.c:616:14: note: initialize
      the variable 'attr' to silence this warning
    long attr;
             ^
              = 0
6 warnings generated.
msg203512 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-11-20 17:14
New changeset 4f0f496e482e by Larry Hastings in branch 'default':
Issue #19474: Argument Clinic now always specifies a default value for
http://hg.python.org/cpython/rev/4f0f496e482e
msg203513 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2013-11-20 17:14
Sigh.  If dataflow analysis could inline the static _impl function, it would notice that there are no code paths where the variable is uninitialized and gets used.  But I'm not surprised compilers aren't that sophisticated.

So I beat the problem to death with a shoe: now, variables that are in option groups that don't otherwise have a default value always get one.
History
Date User Action Args
2022-04-11 14:57:53adminsetgithub: 63673
2013-11-20 17:14:53larrysetstatus: open -> closed
resolution: fixed
messages: + msg203513

stage: resolved
2013-11-20 17:14:30python-devsetnosy: + python-dev
messages: + msg203512
2013-11-01 14:32:12brett.cannoncreate