Remove some implicit conversions#4447
Merged
vitaut merged 3 commits intofmtlib:masterfrom May 24, 2025
Merged
Conversation
The "1" used for the bitshift is treated as int, and this causes an implicit conversion to `UInt` when performing the logical and. Explicitly casting the number to `UInt` avoids the warning.
Some indices in `include/fmt/base.h` are expressed as `int` types, which causes an implicit conversion to a `size_t` when they are actually used as index. Explicitly casting the value avoids the warning.
The number of bits is used to express the size of a buffer. Using an `int` causes an implicit conversion warning, let's use a `size_t` which is the right type for the job.
vitaut
requested changes
May 14, 2025
Contributor
vitaut
left a comment
There was a problem hiding this comment.
Please provide a godbolt repro demonstrating the warnings.
Contributor
Author
The warnings appear when The best way to reproduce the warnings is just enable the warnings during the compilation of cmake -B build -DCMAKE_CXX_FLAGS="-Wconversion -Wsign-conversion"
cmake --build build -j $(nproc) |
Contributor
|
We mostly care about |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes some implicit conversions that can cause noise when compiling other projects if conversions warnings (
-Wconversion -Wsign-conversionin GCC) are enabled.