Skip to content

Conversation

@nlohmann
Copy link
Owner

The serialization of floating-point numbers is handled in two code paths. If number_float_t is an IEEE-754 single or double precision number, the Grisu2 algorithm is used. Otherwise, the serialization is done via std::snprintf. By updating cppcheck to 1.5.1, it warns that the used specifier "%.*g" only works with double.

This PR adds a conversion to double in the std::snprintf call to silence this warning.

Closes #4755

Signed-off-by: Niels Lohmann <[email protected]>
@coveralls
Copy link

Coverage Status

coverage: 99.188%. remained the same
when pulling dfb9eb6 on issue4755-cppcheck-warning
into 51a77f1 on develop.

@nlohmann nlohmann marked this pull request as ready for review May 16, 2025 17:56
@nlohmann nlohmann added the review needed It would be great if someone could review the proposed changes. label May 16, 2025
@nlohmann nlohmann added this to the Release 3.12.1 milestone May 16, 2025
@github-actions github-actions bot added L and removed M labels May 17, 2025
@github-actions
Copy link

This pull request has been marked as stale because it has had no activity for 30 days. While we won’t close it automatically, we encourage you to update or comment if it is still relevant. Keeping pull requests active and up-to-date helps us review and merge changes more efficiently. Thank you for your contributions!

@github-actions github-actions bot added the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Jun 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CMake L review needed It would be great if someone could review the proposed changes. state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix cppcheck 1.5.1 warning

4 participants