-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Correct test of OptionsImpl argc type (Was: Correct type for std::array size() result) #9290
Correct test of OptionsImpl argc type (Was: Correct type for std::array size() result) #9290
Conversation
The std::array API uses std::size_t for the size() nelts count. This is a larger sized int than 'int', which causes this code to break on Windows compilation. Use the stdcxx type for conformance and portability. Signed-off-by: Sunjay Bhatia <[email protected]> Signed-off-by: William A Rowe Jr <[email protected]>
Signed-off-by: Sunjay Bhatia <[email protected]> Signed-off-by: William A Rowe Jr <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This generally seems like the right thing to do when considering array sizes etc but is this the only case where this fails to compile on Windows? There are a lot of examples of for (int i = ..
in the code base.
@bryce-anderson This pattern of changes around As for the |
While I'm not a core maintainer so my opinion is mostly for funzies, I generally approve of cleaning up size types to be more consistent with container size types so I'm 👍 on this.
Sounds good. I assumed so, but was curious.
Sorry, I wasn't clear. I understand why you made the change in this commit and was just noting that this should probably be done in most places where there is a |
In many cases this is simply not necessary. For example, int can often be the index without ambiguity, it is the size of size_t or smaller, and depending on the comparison the signedness isn't an issue. We are resolving this in a number of other files, but they don't need to be corrected en-mass. |
And sometimes the best solution will be an auto. But not in this case, where it is the declarations of args or retval types that are at issue. The alternate patch to this file is to downcast to int, which introduces it's own set of issues. |
- Reverts the prior proposal - Overrides the std::array in tests to emulate argc/argv from main() Signed-off-by: William A Rowe Jr <[email protected]>
After looking at your observations, it is pretty clear the main source/ was correct. Our test/ was supposed to emulate main(argc, argv), so I think the current PR is the more correct solution. |
* master: (167 commits) stats: Avoid asserts in fuzz-tests by eliminating arbitrary length limits, using the new MemBlock wrapper for memcpy (envoyproxy#8779) Make %UPSTREAM_LOCAL_ADDRESS% access-log format work for HTTP requests. (envoyproxy#9362) tools: API boosting support for using decls and enum constants. (envoyproxy#9418) Fix incorrect cluster InitializePhase type (envoyproxy#9379) build: fix merge race between envoyproxy#9241 and envoyproxy#9413. (envoyproxy#9427) fuzz: fix incorrect evaluator test (envoyproxy#9402) server: fix bogus startup log message (envoyproxy#9404) tools: Add protoxform tests (envoyproxy#9241) api: options after import (envoyproxy#9413) misc: use std::move instead of constructing a copy (envoyproxy#9415) tools: API boosting support for rewriting elaborated types. (envoyproxy#9375) docs: fix invalid transport_socket value (envoyproxy#9403) fix typo in docs (envoyproxy#9394) srds: remove to-de-removed scopes first and then apply additions to avoid scope key conflict. (envoyproxy#9366) api: generate whole directory and sync (envoyproxy#9382) bazel: Add load statements for proto_library (envoyproxy#9367) Fix typo (envoyproxy#9388) Correct test of OptionsImpl argc type (Was: Correct type for std::array size() result) (envoyproxy#9290) http1 encode trailers in chunk encoding (envoyproxy#8667) Add mode to PipeInstance (envoyproxy#8423) ...
…ay size() result) (envoyproxy#9290) The std::array API uses std::size_t for the size() nelts count. This is a larger sized int than 'int', which causes this code to break on Windows compilation. Use the stdcxx type for conformance and portability. Signed-off-by: Sunjay Bhatia <[email protected]> Signed-off-by: William A Rowe Jr <[email protected]> Signed-off-by: Prakhar <[email protected]>
Description:
The std::array API uses std::size_t for the size() nelts count.
This is a larger sized int than 'int', which causes this code
to break on Windows compilation.
Follow the conventional declaration of main(int argc, ...
and adjust the tests of OptionsImpl accordingly.
Original Description:
Use the stdcxx type for conformance and portability.
Signed-off-by: Sunjay Bhatia [email protected]
Signed-off-by: William A Rowe Jr [email protected]
Risk Level: Low
Testing: Local on Windows, Linux gcc
Docs Changes: N/A
Release Notes: N/A