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
emit-c: a function returning an array returns a pointer to its own dead local, and the call site assigns an array #1775
fn arr() -> [u16; 2]: [7u16, 9u16]
fn main:
let a = arr()
print(a[1])
--emit-c (base 76cf0bf stage1): the function is emitted as uint16_t* arr__N() returning its local _0 (a pointer to a dead stack array), and the call site assigns the result to an array local, which clang refuses: "array type 'uint16_t[2]' is not assignable". The LLVM backend prints 9.
Expected: an array return crosses by value (a struct wrapper, or an out-pointer the caller provides), never as a pointer to the callee's frame. Found while writing #1484 (whose startup initializers store through the global instead for this reason).
Activity
emit-c: a function returning an array takes the destination as an out…
emit-c: a function returning an array takes the destination as an out…
c_import/migrate/emit-c: no `-> Unit` on void C fns (#1838); header f…