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 static inline function that calls a raw prototype (e.g. a variadic one) does not compile #1830
A static inline body that calls a raw c_import function is translated as a safe fn with the raw call unwrapped, so the translation fails Sema:
use c_import("int vd_sum(int n, ...);\nstatic inline int vd_call_sum(void) { return vd_sum(4, 10, 20, 12, 18); }\n")
fn main:
print(vd_call_sum())
error: raw c_import function call requires unsafe context
34 | return vd_sum((4 as c_int), 10, 20, 12, 18)
(v0.15.2.1 and the D75 branch.) ci_translate_function decides si_raw (→ unsafe fn) from the inline function's own signature only; the migrate path wraps raw calls via g_migrate_unsafe_extern_fn_names, which c_import never fills. Per D51 the inline wrapper should not become safe by inference: the translated function should be unsafe fn when its body calls a raw function (or translation should fail loudly naming the raw callee), never compile-fail on generated text.
Found while writing the C-caller test for D75 variadic definitions (#1678); that test uses a C harness linked with --link-object instead.
Activity
c_import: an inline function whose body calls a raw C function is an …