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

Mark variables as initialized [cleaned up version] #14403

Merged
merged 1 commit into from
Dec 17, 2015

Conversation

drepper
Copy link
Contributor

@drepper drepper commented Dec 14, 2015

The compiler often cannot see through the tangle of code to make
100% correct deduction about whether a variable is initialized or
not. It usually errs on the side of caution and emits a warning.

One example is in codegen.cpp:emit_function where the variable SP
is only ever used when at the same time ctx.debug_enabled is set
to true. The compiler (at least gcc 5.x) doesn't keep track of
this relationship.

From my experience this kind of problem often appears in large
code bases which is why I'm kind of surprised I couldn't find a
framework to handle them. This is why I'm proposing the following
change.

Instead of adding one kludgy workaround here a macro JL_MARK_INITIALIZED
is introduced. When correctly defined (as I do it for gcc) this macro
creates no additional cost in the generated code while preventing the
warning. Definitions for other compilers should be added appropriately.

The compiler often cannot see through the tangle of code to make
100% correct deduction about whether a variable is initialized or
not.  It usually errs on the side of caution and emits a warning.

One example is in codegen.cpp:emit_function where the variable SP
is only ever used when at the same time ctx.debug_enabled is set
to true.  The compiler (at least gcc 5.x) doesn't keep track of
this relationship.

From my experience this kind of problem often appears in large
code bases which is why I'm kind of surprised I couldn't find a
framework to handle them.  This is why I'm proposing the following
change.

Instead of adding one kludgy workaround here a macro JL_MARK_INITIALIZED
is introduced.  When correctly defined (as I do it for gcc) this macro
creates no additional cost in the generated code while preventing the
warning.  Definitions for other compilers should be added appropriately.
@pao
Copy link
Member

pao commented Dec 14, 2015

cf #14352 (previous version of this patch)

@drepper
Copy link
Contributor Author

drepper commented Dec 17, 2015

Anyone want to take a look at this? There shouldn't be a problem and it gets rid of the ugly and scary-looking last warning during the build.

@Keno
Copy link
Member

Keno commented Dec 17, 2015

Fine with me.

Keno added a commit that referenced this pull request Dec 17, 2015
Mark variables as initialized [cleaned up version]
@Keno Keno merged commit 1e7e967 into JuliaLang:master Dec 17, 2015
yuyichao added a commit that referenced this pull request Jan 13, 2016
…break if

any change is made to the code and incorrectly suppress the compiler warning.

Revert #14403. Close #14595
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.

None yet

3 participants