Skip to content

Fix variable initialization due to jump bypassing it #23051

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

Merged
merged 1 commit into from
May 17, 2022
Merged

Fix variable initialization due to jump bypassing it #23051

merged 1 commit into from
May 17, 2022

Conversation

Biswa96
Copy link
Contributor

@Biswa96 Biswa96 commented May 15, 2022

PR Summary

This fixes the following error in mingw gcc toolchain. Also clang
also have same error.

src/_tkagg.cpp:274:26: note:   crosses initialization of 'bool tk_ok'
  274 |     bool tcl_ok = false, tk_ok = false;
      |                          ^~~~~
src/_tkagg.cpp:274:10: note:   crosses initialization of 'bool tcl_ok'
  274 |     bool tcl_ok = false, tk_ok = false;
      |          ^~~~~~

According to C++ standard (6.7.3):

It is possible to transfer into a block, but not in a way that bypasses
declarations with initialization. A program that jumps from a point where
a variable with automatic storage duration is not in scope to a point
where it is in scope is ill-formed unless the variable has scalar type...

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

This fixes the following error in mingw gcc toolchain. Also clang
also have same error.

src/_tkagg.cpp:274:26: note:   crosses initialization of 'bool tk_ok'
  274 |     bool tcl_ok = false, tk_ok = false;
      |                          ^~~~~
src/_tkagg.cpp:274:10: note:   crosses initialization of 'bool tcl_ok'
  274 |     bool tcl_ok = false, tk_ok = false;
      |          ^~~~~~

According to C++ standard (6.7.3):
It is possible to transfer into a block, but not in a way that bypasses
declarations with initialization. A program that jumps from a point where
a variable with automatic storage duration is not in scope to a point
where it is in scope is ill-formed unless the variable has scalar type...
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a while, please feel free to ping @matplotlib/developers or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide

We strive to be a welcoming and open project. Please follow our Code of Conduct.

@tacaswell tacaswell added this to the v3.5.3 milestone May 15, 2022
@tacaswell
Copy link
Member

tacaswell commented May 15, 2022

Thank you!

This fix is also included in #22999 [edit correct PR number]

@Biswa96
Copy link
Contributor Author

Biswa96 commented May 15, 2022

Should I close this?

@DWesl
Copy link
Contributor

DWesl commented May 17, 2022

Given that #22999 is failing with error message "command did not succeed", it might be a while before that goes in.

Copy link
Member

@QuLogic QuLogic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure there's actually a problem here, but if it fixes a warning, then LGTM.

@anntzer
Copy link
Contributor

anntzer commented May 17, 2022

Thanks for the fix, hoping to see you around again.

@anntzer anntzer merged commit f25c2d0 into matplotlib:main May 17, 2022
@Biswa96 Biswa96 deleted the fix-error-mingw branch May 17, 2022 12:17
@tacaswell
Copy link
Member

@meeseeksbot please backport to v3.5.x

@QuLogic
Copy link
Member

QuLogic commented May 18, 2022

meeseeksdev backport to v3.5.x

@tacaswell
Copy link
Member

thank you @QuLogic .

QuLogic added a commit that referenced this pull request May 18, 2022
…051-on-v3.5.x

Backport PR #23051 on branch v3.5.x (Fix variable initialization due to jump bypassing it)
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.

5 participants