Skip to content

codegen: a str lent to a translated inline C function's const char * is a C string (#1589) - #1729

Merged
ehartford merged 1 commit into
mainfrom
cstr-lend-translated-inline
Sep 26, 2026
Merged

ehartford merged 1 commit into
mainfrom
cstr-lend-translated-inline

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

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.

…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
@ehartford

Copy link
Copy Markdown
Contributor Author

Seed-driven battery green on 233cf4f (alone; host darwin-aarch64, seed per seed.lock):

cstr-lend build  rc=0
cstr-lend build :fixpoint rc=0
cstr-lend build :test rc=0
cstr-lend build :test-green rc=0
cstr-lend build :last-green rc=0
cstr-lend build :user-programs-safe rc=0

@ehartford
ehartford marked this pull request as ready for review September 26, 2026 18:57
@ehartford
ehartford merged commit 3ccb998 into main Sep 26, 2026
@ehartford
ehartford deleted the cstr-lend-translated-inline branch September 26, 2026 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant