Repository navigation
Fix AppVeyor failures from the Zmij double writer - #5843
Merged
Merged
Conversation
MSVC 2015 warns C4554 on the shifts with casts in the fractional part of zmij::to_shortest despite the parentheses; with /WX every target fails to build. Name the shift amounts as constants instead. The shortest-digits test built the candidates with one digit fewer via a stream with std::setprecision(digits.size() - 2); the standard library of MSVC 2017 ignores a precision of 0, so for two-digit values the "shorter" candidates were the value itself. Truncate the digits instead: the value lies within half a unit of the last digit, so the truncated digits and their successor are the closest candidates. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
gregmarr
approved these changes
Oct 15, 2026
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.
AppVeyor build 9193 on
developfails since #5634 (Zmij double writer):zmij.hpp(187): warning C4554: '<<': check operator precedence— a false positive on(p.high << static_cast<unsigned>(64 - extra_shift)) | (p.low >> static_cast<unsigned>(extra_shift))despite the parentheses; with/W4 /WXnothing builds. The shift amounts are now namedconstexpr unsignedconstants, so the expression has no casts.test-to_chars_cpp17fails 16 checks atunit-to_chars.cpp:713, all for two-digit outputs (0.25,16.0,1.6e-322, …). The test built the one-digit-shorter candidates withstd::scientific << std::setprecision(digits.size() - 2); MSVC 2017's library ignores a precision of 0, so the "shorter" candidate was the value itself. The test now truncates the digits instead: the value lies within half a unit of the last printed digit, so the truncated digits and their successor are the closest shorter candidates (the existingmid - 1, mid, mid + 1loop keeps covering them). The now unused<iomanip>,<sstream>,<locale>includes are dropped.Checked locally with clang (C++11 and C++17,
-Wall -Wextra -Wconversion -Werror): the to_chars test passes with the same 623,597 assertions. Neither MSVC version is available locally, so AppVeyor confirms the fix.Public API
No breaking changes: the library change only renames internal shift amounts in
detail::zmij; output is unchanged.Written by Claude Code.
🤖 Generated with Claude Code