Fix: Correct narrowing conversion in lsx string parsing#2481
Merged
lemire merged 1 commit intosimdjson:masterfrom Sep 29, 2025
Merged
Fix: Correct narrowing conversion in lsx string parsing#2481lemire merged 1 commit intosimdjson:masterfrom
lemire merged 1 commit intosimdjson:masterfrom
Conversation
Resolves a build failure on the loong64 architecture caused by a narrowing conversion error. The compiler, with the -Werror=narrowing flag, was flagging the implicit conversion from 'int' (the return type of to_bitmask()) to 'uint64_t'. This is fixed by adding an explicit static_cast to uint64_t in include/simdjson/lsx/stringparsing_defs.h. Signed-off-by: Zhou Qiankang <wszqkzqk@qq.com>
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.
Short title (summary): Fix compiler error on loong64 by correcting narrowing conversion
Description
Fixed a narrowing conversion that caused build failures on the loong64 architecture. The to_bitmask() function
returns an int, which was being assigned to a uint64_t variable, causing a compiler error with the
-Werror=narrowing flag. This was resolved by adding an explicit static_cast<uint64_t> to the return value.
Type of change
How to verify / test
This change can be verified by building on Arch Linux for Loong64 where the build was
previously failing due to the narrowing conversion error. A successful build confirms the fix.
All the tests pass now.
Here is the log:
Please read before contributing:
If you can, we recommend running our tests with the sanitizers turned on.
For non-Visual Studio users, it is as easy as doing:
Our CI checks, among other things, for trailing whitespace. If a test fails for that reason,
use the "artifacts" button to download the artifact and inspect the problematic lines,
or run
scripts/remove_trailing_whitespace.shlocally if you have a bash shell andsed.Checklist before submitting
Final notes
Thanks for the contribution!