You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
c_import: a user module's <string.h> memchr wrapper hijacks std.re's memchr when std.re compiles from source (stage1) #1485
Found while fixing #1417. Stage1 of main (the bootstrap compiler, which has no embedded .wo bundles and compiles std.re from source):
use c_import("<string.h>")
fn main:
print("x")
error: function 'memchr' expects 2 argument(s), found 3
--> lib/std/re/pcre2_match.w:1450:48
error: wrong argument type in call to 'memchr'
--> lib/std/re/pcre2_match.w:1450:55
= note: parameter '__s' expects []u8
= note: actual type: *mut c_void
(12 of each; the release binary runs it, because it links std.re's bundle instead of checking its source.)
The root's <string.h> import emits the #379 buf wrapper fn memchr(__s: []u8, __c: c_int) -> ... (the raw extern renamed to __wc_buf_memchr), and std.re.pcre2_match's memchr(ptr, c, n) — which means std.re.defs' pub extern fn memchr(s: *const c_void, c: i32, n: i64) — resolves to the user module's c_import wrapper. A std implementation module must never resolve a user-tier declaration (D29 rule 1, "std blindness"); Not yet located at the line; a likely route (unverified) is symbol_visible_from_current returning 1 early for a ci_syms member that is_ci_visible (Sema.w), before the tier rules run, with one flat memchr signature.
Expected: std.re binds its own memchr whatever the user module c_imports; the program prints x on stage1 as on the release binary. Every stage1 test of a c_import that includes <string.h> (directly or through windows.h) is blocked by this today.
Activity
c_import: windows.h type-checks — bodies over opaque records omitted,…
c_import: windows.h type-checks — bodies over opaque records omitted,…
ehartford commentedon Sep 26, 2026
Duplicate of #1663 (c_import's memchr wrapper vs std.re's extern — per-module symbol identity); tracked there.