8000 gh-112301: fix compiler warning about a possible use of an uninitialized variable by carsonRadtke · Pull Request #112308 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

0