Fix debug format width calculation - #4902
Open
Satyakam-Mishra wants to merge 1 commit into
Open
Conversation
Satyakam-Mishra
force-pushed
the
fix-debug-width-4901
branch
from
August 29, 2026 05:06
514a09d to
39b1eb0
Compare
vitaut
requested changes
Aug 30, 2026
Comment on lines
+1912
to
+1914
| counting_buffer<Char> buf; | ||
| write_escaped_char(basic_appender<Char>(buf), value); | ||
| size = buf.count(); |
Contributor
There was a problem hiding this comment.
counting_buffer seems pretty heavyweight here for an output that is at most 12 characters. Could we format once into a small local buffer and use its size for padding, then copy it to the output? Something along the lines of
Char buf[12];
auto* begin = buf;
auto* end = begin;
size_t size = 1;
if (is_debug) {
end = write_escaped_char(begin, value);
size = to_unsigned(end - begin);
}
return write_padded<Char>(out, specs, size, [=](auto it) {
if (is_debug) return copy<Char>(begin, end, it);
*it++ = value;
return it;
});
Author
There was a problem hiding this comment.
Thanks! I have updated the implementation to use a small local buffer as suggested, and the tests and clang-format-21 checks passes.
Satyakam-Mishra
force-pushed
the
fix-debug-width-4901
branch
from
August 30, 2026 18:29
39b1eb0 to
3a7692b
Compare
Satyakam-Mishra
force-pushed
the
fix-debug-width-4901
branch
from
August 31, 2026 05:45
3a7692b to
374abbd
Compare
Author
|
Updated the implementation to use reserve_iterator instead of generic auto lambda parameter, which was causing the CI build failure with the older compiler. The changes are pushed and the local tests are passing |
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.
Fixes #4901.
The width calculation for debug-formatted characters and strings was based on the unescaped output size. This caused incorrect padding for debug characters and could truncate the closing quote for empty debug strings.
This change:
All tests pass locally.