Fix a gcc -Werror=maybe-uninitialized warning in LTO mode. #3562
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
We have a gcc warning (error in our case since we use -Werror) when building some of our own code in LTO (link time optimisation) mode + statically linking curl which was also built with LTO mode. In practice, gcc will try at link time to optimize the whole program (so our own code + the curl code) in one go.
When doing that, with flags -Werror -Wall -Wextra, we get this warning (error):
I checked the code, and this definitely looks like a false positive (gcc generates quite often false positives with -Wmaybe-uninitialized which is implied by -Wall/-Wextra). I propose to silence the false positive by actually initializing the value even if it's useless. If that does not fly for you, we might consider another fix which is adding a pragma diagnostic to actually ignore this warning, that's up to you.
Cheers,
Romain