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

Fix: GCC warns about possibly uninitialized data in signal.cpp #8281

Merged
merged 1 commit into from Jul 27, 2020

Conversation

techgeeknz
Copy link
Contributor

When compiling with -Og, GCC warns about variables that are initialized by reference in the condition of a while loop.

This commit silences the warning by explicitly initializing the variables in question to their respective 'invalid value' markers, which will most likely be optimized out when the compiler realizes the values are never used.

As near as I can tell, the compiler complains because there is a path through SmallSet::Get that does not assign to its parameters (i.e. the case of an empty set); and the optimization level in question does not perform the static analysis that would be necessary to determine that the results (or lack thereof) are not actually used in that case.

Fixes #8280

When compiling with '-Og', GCC warns about variables that are
initialized by reference in the condition of a 'while' loop.

This commit silences the warning by explicitly initializing the
variables in question to their respective 'invalid value' markers,
which will most likely be optimized out when the compiler realizes
the values are never used.
@LordAro LordAro merged commit c0bf7cc into OpenTTD:master Jul 27, 2020
@techgeeknz techgeeknz deleted the tiledir_compile_warning branch July 28, 2020 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GCC complains about possibly uninitialized variables when compiling with CXXFLAGS='-Og -g'
2 participants