json icon indicating copy to clipboard operation
json copied to clipboard

Fix cppcheck warning

Open nlohmann opened this issue 8 months ago • 2 comments

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

nlohmann avatar Apr 24 '25 06:04 nlohmann

Coverage Status

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

coveralls avatar Apr 24 '25 07:04 coveralls

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[bot] avatar Jun 17 '25 00:06 github-actions[bot]