forked from ponylang/ponyc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Small steps towards enabling -Wsign-conversion for some submodules (p…
…onylang#3413) * libponyc: Be more explicit about return std::move(error) Doing `return std::move(value)` is, in general, not a good idea, and GCC warns about it. ``` src/libponyc/codegen/genjit.cc: In lambda function: src/libponyc/codegen/genjit.cc:46:34: error: redundant move in return statement [-Werror=redundant-move] 46 | if (err) return std::move(err); | ~~~~~~~~~^~~~~ src/libponyc/codegen/genjit.cc:46:34: note: remove ‘std::move’ call ``` But in this case, this warning is a false-positive. What's happening is an implicit conversion from `Error &&` to `JITSymbol`. Changing the code to be explicit rather than implicit fixes the warning and makes the code more clear. * benchmark: Make all sign conversions explicit * test: Make all sign conversions explicit * Explicitly cast list length to a signed type to sum with negative Nothing in the generated code will change duo this (see https://godbolt.org/z/n6Dkdp), but it makes it more clear what's happening and doesn't violate -Wsign-conversion (which I plan to enable). Without this change, clang reports: src/libponyrt/ds/list.c:52:39: error: implicit conversion changes signedness: 'unsigned long' to 'ssize_t' (aka 'long') [-Werror,-Wsign-conversion] index = ponyint_list_length(list) + index; ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ src/libponyrt/ds/list.c:52:41: error: implicit conversion changes signedness: 'ssize_t' (aka 'long') to 'unsigned long' [-Werror,-Wsign-conversion] index = ponyint_list_length(list) + index; ~ ^~~~~ * Cast the result of __builtin_* calls to unsigned types The GCC/clang builtins listed here return int even though they never return a negative number. The __pony_* wrappers of these builtins all return unsigned and most of the use-cases of the builtins make sense with the unsigned result, so I think it makes sense to have unsigned return as the default for all platforms. This change means we don't have to add many explicit casts in the calls to __pony_* to fix -Wsign-conversion violations.
- Loading branch information
1 parent
86f030a
commit bfc9b86
Showing
10 changed files
with
51 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.