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 a gcc -Werror=maybe-uninitialized warning in LTO mode. #3562

Conversation

Romain-Geissler-1A
Copy link
Contributor

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):

hostip.c: In function ‘Curl_resolv’:
hostip.c:585:9: error: ‘respwait’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
hostip.c:551:9: note: ‘respwait’ was declared here

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

@bagder
Copy link
Member

bagder commented Feb 12, 2019

Thanks!

@bagder bagder closed this in aa1f1d4 Feb 12, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants