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 call through an unprototyped declaration (int f();) uses the variadic convention — wrong arguments on darwin arm64 #1831
libclang reports every FunctionNoProto type as variadic, so int knr(); is imported as extern fn knr(...) -> c_int and its calls use the variadic calling convention. A K&R definition is not variadic: on darwin arm64 the variadic convention puts every argument on the stack while the definition reads x0/x1.
// knr.cintknr(a, b) inta, b; { returna*10+b; }
use c_import("int knr();")
fn main:
print(unsafe { knr(4, 2) })
clang -c knr.c && with build main.w --link-object knr.o → prints 0 (expected 42).
C calls an unprototyped function with the non-variadic convention after the default argument promotions. The D75 branch (#1678) fixes the definition side (a K&R definition in the unit is no longer imported as fn f(...)), but a declaration-only no-proto function still takes this path. Modeling it needs either a per-call promoted non-variadic signature or a loud refusal of calls with arguments; never the variadic ABI.
Activity
c_import: an unprototyped call passes promoted arguments with the fix…
Variadic calls pass each `...` argument after the default argument pr…
@[c_export] of a declared symbol: a conflicting definition is refused…
C migrator: a declaration without a prototype becomes the prototype i…
Seven compiler fixes: literals at distinct demands (D153), element-pl…