Skip to content

Fix a gcc -Werror=maybe-uninitialized warning in LTO mode. - #3562

Closed
Romain-Geissler-1A wants to merge 1 commit into
curl:masterfrom
Romain-Geissler-1A:fix-maybe-uninitialized-warning
Closed

Romain-Geissler-1A wants to merge 1 commit into
curl:masterfrom
Romain-Geissler-1A:fix-maybe-uninitialized-warning

Conversation

@Romain-Geissler-1A

Copy link
Copy Markdown
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

bagder commented Feb 12, 2019

Copy link
Copy Markdown
Member

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.

2 participants