-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
rustc_llvm: Fix flattened CLI args #131805
Conversation
Fixes string manipulation errors introduced in rust-lang#130446.
r? augie |
Failed to set assignee to
|
r? durin42 |
This comment has been minimized.
This comment has been minimized.
Thanks. I'm... actually not sure how rustc finished bootstrap on the LLVM 20 integration build with this error? It has built since then, right? |
This only affects the command line portion in debug info on windows AFAIK. The only reason we found this was because we had tests for deterministic builds on windows, and the bad strings were sometimes garbage. |
huuuh.
|
auto ArgsCppStr = std::string(ArgsCstrBuff + buffer_offset, | ||
ArgsCstrBuffLen - buffer_offset); | ||
auto i = 0; | ||
while (i != std::string::npos) { | ||
i = ArgsCppStr.find('\0', i + 1); | ||
if (i != std::string::npos) | ||
ArgsCppStr.replace(i, i + 1, " "); | ||
ArgsCppStr.replace(i, 1, " "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, re-reading the reference about std::string::npos
, I think I may have misunderstood something about it.
Why is it correct at all as part of a conditional expression like a while
or if
? It only takes on its magic "until the end of the string" meaning when used as an argument to std::string
's functions, doesn't it? Which the control-flow expressions are not invocations of.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://cplusplus.com/reference/string/string/find/
Return Value
The position of the first character of the first match.
If no matches were found, the function returns string::npos.
npos
isn't magic, it's in practice just a way to say -1
. find() returns npos if something isn't found, and at that point we don't take this if / exit the loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, okay!
@bors r+ rollup |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#129620 (Provide a more convinient way of developing rustc on NixOS) - rust-lang#131805 (rustc_llvm: Fix flattened CLI args) - rust-lang#131818 (Enable XRay instrumentation for LoongArch Linux targets) - rust-lang#131825 (SolverDelegate add assoc type for Infcx) - rust-lang#131833 (Add `must_use` to `CommandExt::exec`) - rust-lang#131835 (Do not run test where it cannot run) - rust-lang#131844 (Add mailmap entry for kobzol) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#131805 - aeubanks:flat, r=durin42 rustc_llvm: Fix flattened CLI args Fixes string manipulation errors introduced in rust-lang#130446.
Fixes string manipulation errors introduced in #130446.