Skip to content

Fix warning for uninitialized va_list variable. #17944

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

Merged

Conversation

ktopley-apple
Copy link
Contributor

rdar://problem/40626177

Initializes a va_list variable that is currently not initialized. This is purely to silence a compiler warning because the value will not be used.

@ktopley-apple
Copy link
Contributor Author

@swift-ci please smoke test

@jrose-apple
Copy link
Contributor

I'm not sure that's a valid initialization for va_list on all platforms, but I guess it's okay for Darwin. You should land this on master first, though, and then cherry-pick to 4.2.

@ktopley-apple
Copy link
Contributor Author

I don't think there is a globally correct initialization. Fortunately, this only matters for Darwin.

@ktopley-apple ktopley-apple changed the base branch from swift-4.2-branch to master July 13, 2018 21:55
@ktopley-apple ktopley-apple changed the base branch from master to swift-4.2-branch July 13, 2018 21:55
@ktopley-apple ktopley-apple force-pushed the ktopley-oslog-rdar40626177 branch from 337699d to f5255fe Compare July 13, 2018 22:04
@ktopley-apple ktopley-apple changed the base branch from swift-4.2-branch to master July 13, 2018 22:04
@ktopley-apple
Copy link
Contributor Author

@swift-ci please smoke test

1 similar comment
@ktopley-apple
Copy link
Contributor Author

@swift-ci please smoke test

@najacque
Copy link
Contributor

@swift-ci please test macOS platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 337699d7251d5192246ecd6cbc32542b0632977f

@najacque
Copy link
Contributor

@swift-ci please smoke test macOS platform

@jrose-apple
Copy link
Contributor

That error is actually relevant:

16:36:39 
/Users/buildnode/jenkins/workspace/swift-PR-osx/branch-swift-4.2-branch/swift/stdlib/public/SDK/os/os.m:164:15: error: scalar initializer cannot be empty
16:36:39   va_list x = {};
16:36:39               ^~

If this were a .mm file you'd be okay, but not as a .m.

@jrose-apple
Copy link
Contributor

I guess this is a good reminder not to just do smoke tests if you're dealing with something that might be platform-specific.

@ktopley-apple ktopley-apple force-pushed the ktopley-oslog-rdar40626177 branch from f5255fe to fc08a12 Compare July 17, 2018 15:22
@ktopley-apple
Copy link
Contributor Author

@swift-ci please test

@ktopley-apple
Copy link
Contributor Author

@swift-ci please test macOS platform

@ktopley-apple
Copy link
Contributor Author

@swift-ci please test Linux platform

@ktopley-apple
Copy link
Contributor Author

@swift-ci please smoke test macOS platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - f5255fed188244f2d4740e61f0f00a1022ac4c34

@ktopley-apple
Copy link
Contributor Author

@swift-ci please smoke test Linux platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 337699d7251d5192246ecd6cbc32542b0632977f

@ktopley-apple
Copy link
Contributor Author

@swift-ci test Linux platform

@ktopley-apple
Copy link
Contributor Author

It seems that this works:

static va_list x;

We can use a static whether or not it gets copied on function calls because in this case we know that the value is not going to be used (and definitely not mutated).

@jrose-apple
Copy link
Contributor

Clever enough answer. I wish there was something more semantic, but this is probably fine. (Just silencing the warning on that particular line of code using pragmas probably would have been fine too.)

@ktopley-apple
Copy link
Contributor Author

I was never able to get the warning when building outside of CI. I would like to understand why that is, when I have time to look more closely.

@ktopley-apple ktopley-apple merged commit 53e039b into swiftlang:master Jul 18, 2018
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.

5 participants