hsutter / cppfront

A personal experimental C++ Syntax 2 -> Syntax 1 compiler
Other
5.24k stars 223 forks source link

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

Closed bluetarpmedia closed 5 months ago

bluetarpmedia commented 5 months ago

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.

hsutter commented 5 months ago

Thanks!

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