Skip to content

behav_c_facade_libc_system_headers.w fails on main: c_import's modeled memchr(s: []u8, c) wrapper from <string.h> captures std.re's own memchr extern calls in pcre2_match.w #1663

Closed

Description

@ehartford

Verified on a pristine origin/main worktree (276dbf3) with a seed-built stage1 (with build :dev, seed ~/with/src/main):

./out/bootstrap/bin/with-stage1 test test/behavior/behav_c_facade_libc_system_headers.w
error: function 'memchr' expects 2 argument(s), found 3
 --> lib/std/re/pcre2_match.w:1450:48
1450 |         (… = ((memchr(((… as *const c_void) as *mut c_void), (… as c_int), (… as c_ulong)) as *const u8)))
  = note: parameter '__s' expects []u8
  = note: actual type: *mut c_void

The fixture c_imports <string.h>; c_import renders its built-in byte-buffer contract for memchr (CImport.w: memchr → buffer param 0, len param 2 — the D47/#1300 modeled contracts) as a memchr(__s: []u8, __c) wrapper. lib/std/re/defs.w declares its own pub extern fn memchr(s: *const c_void, c: i32, n: i64), and pcre2_match.w's calls to that extern resolve to the user program's c_import wrapper instead — the same-named-extern hazard the text-view path guards against (SemaFacade.w facade_call_is_presented: "a module with its own same-named extern (std.re's strchr) is not presented"), unguarded for c_import's own modeled wrappers. Any program that imports <string.h> and uses std.regex (or the prelude's std.re bundle) hits it — the D66 probe program did too before its fixture header moved to hand-written prototypes.

Same failure with the D66 branch's stage1; the fixture is the only red in the facade sweep there (behavior/compile_errors/debug_alloc facade fixtures otherwise green), so it is not a D66 regression.

Route: resolve memchr (and every modeled wrapper) per module — a call resolves to the c_import wrapper only in a module that imported that header and has no declaration of its own for the name; std.re's calls stay on std.re's extern.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions