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

Add a static_cast in args_t::size to silence a conversion warning #966

Merged
merged 2 commits into from
Feb 6, 2024

Conversation

bluetarpmedia
Copy link
Contributor

Clang reports this warning in cpp2util.h when -Wconversion is enabled:

cpp2util.h:1774:49: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
 1774 |     auto size()   const -> std::size_t { return argc; }
      |                                          ~~~~~~ ^~~~

So this PR adds a static_cast to silence the warning and show that the conversion is intentional.

bluetarpmedia and others added 2 commits February 6, 2024 10:38
Signed-off-by: Neil Henderson <2060747+bluetarpmedia@users.noreply.github.com>
I know, but negative numbers...
@hsutter
Copy link
Owner

hsutter commented Feb 6, 2024

Thanks!

Minor nit: Sadly, because of the dratted silliness of mixed signedness, this needs to be unsafe_narrow...

@hsutter hsutter merged commit 0ac5ca6 into hsutter:main Feb 6, 2024
15 checks passed
bluetarpmedia added a commit to bluetarpmedia/cppfront that referenced this pull request Feb 7, 2024
…hsutter#966)

* Add a static_cast in `args_t::size` to silence a conversion warning

Signed-off-by: Neil Henderson <2060747+bluetarpmedia@users.noreply.github.com>

* Change `static_cast` to `unsafe_narrow`

I know, but negative numbers...

---------

Signed-off-by: Neil Henderson <2060747+bluetarpmedia@users.noreply.github.com>
Co-authored-by: Herb Sutter <herb.sutter@gmail.com>
@bluetarpmedia bluetarpmedia deleted the args-static-cast branch February 7, 2024 05:04
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.

2 participants