Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-112301: fix compiler warning about a possible use of an uninitialized variable #112308

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

carsonRadtke
Copy link
Contributor

@carsonRadtke carsonRadtke commented Nov 22, 2023

In #112301, @mdboom posted a proposal for adding some recommended compiler flags.

This PR addresses a single class of warnings (-Wmaybe-uninitialized) that may crop up if we were to switch to the "hardened" build command.

Specific build error:

./Modules/_io/fileio.c:175:9: warning: ‘exc’ may be used uninitialized [-Wmaybe-uninitialized]
  175 |         _PyErr_ChainExceptions1(exc);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./Modules/_io/fileio.c: In function ‘_io_FileIO_close’:
./Modules/_io/fileio.c:160:15: note: ‘exc’ was declared here
  160 |     PyObject *exc;

@ghost
Copy link

ghost commented Nov 22, 2023

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Nov 22, 2023

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@sethmlarson
Copy link
Contributor

Should we be adding the -Wmaybe-uninitialized option to the build in this PR as well? I think that's coming from -Wall but it's unlikely we enable that option in particular?

@mdboom
Copy link
Contributor

mdboom commented Nov 22, 2023

Should we be adding the -Wmaybe-uninitialized option to the build in this PR as well? I think that's coming from -Wall but it's unlikely we enable that option in particular?

Alternatively, should we be adding -Werror=maybe-uninitialized which would error if this kind of thing ever crept back in? IMHO, warnings almost always just get ignored. I'm pretty comfortable that this warning is just a bunch of false positives that are hard to fix. On the other hand, we should probably build consensus before adding new error types. (Probably a discussion to have in the general sense over on #112301).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants