-
Notifications
You must be signed in to change notification settings - Fork 894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cxxrtl: use octal encoding of non-printables. #4567
base: main
Are you sure you want to change the base?
Conversation
"\x0a" is a perfectly valid escape sequence, but unfortunately "\x0ac" is equivalent to "\xac", and not "\x0a" "c" as we might expect --- *any* number of hexadecimal characters after the "\x" is accepted. This can be hit pretty easily if a newline is present in a format string. "\x{...}" syntax is only available as of C++23, so use octal format instead; a maximum of 3 digits following the backslash is accepted. The alternative would be to render every escape like `" "\x0a" "`, but it seems more effort that way.
Oh oops, I could swear I've fixed this--I remember making a poll recently where basically nobody got it right. (Including me, evidently. I have no idea what that was about then...) Thanks for fixing this! |
Oh, I see, you're applying the change in commit 43ddd89 to |
Oh! Yeah, I didn't even see that either; amusing that we ended up writing almost exactly the same thing — but that one looks subtly wrong? The low and middle parts only have two significant bits each ( |
Oh. <.<
Please do. <.< (What an embarrassing mistake...) |
Hehehe, nah, very easy to do. (Just thinking about "3 bits" and I nearly wrote the exact same.) I did a bunch of manual tests just to make sure I wasn't making a subtly incorrect thing even subtly-er worse; for a bit I was outputting absolute garbage due to signed integer behaviour <_> |
"\x0a"
is a perfectly valid escape sequence, but unfortunately"\x0ac"
is equivalent to"\xac"
, and not"\x0a" "c"
as we might expect --- any number of hexadecimal characters after the\x
is accepted. This can be hit pretty easily if a newline is present in a format string."\x{...}"
syntax is only available as of C++23, so use octal format instead; a maximum of 3 digits following the backslash is accepted.The alternative would be to render every escape like
" "\x0a" "
, but it seems more effort that way.cc @whitequark.