Repository navigation
codegen: a str lent to a translated inline C function's const char * is a C string (#1589) - #1729
Merged
Merged
Conversation
…is a C string (#1589, §16.3c, D47) Sema accepts a str/&str for a `const char *` parameter of every c_import-origin callee (try_ci_coercion keys on ci_syms). Codegen lent the C string only when the callee had the C calling convention, which an inline C function translated into With does not have, so it passed the str header's address: strlen counted that pointer's non-zero low bytes. The lend now follows Sema's fact (ci_syms) as well as the convention. The test uses 13-byte strings, a count no pointer's bytes reach; the old test's "hello" matched the usual 5-byte count and passed by coincidence. Before: 3 or 5 per run. After: 13 on every run. Fixes #1589
Contributor
Author
|
Seed-driven battery green on 233cf4f (alone; host darwin-aarch64, seed per seed.lock): |
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 #1589. Codegen keyed the D47 C-string lend on the C calling convention; Sema accepts the coercion for every c_import-origin callee, including inline C functions translated into With, which passed the str header's address. The lend now follows Sema's ci_syms fact. The test uses 13-byte strings (the old 5-byte test passed by coincidence). Local gate green (build, build.w, abi-hash-check, all corpora, examples). ABI-path change: alone in its battery. Draft until green.