// glob_struct_ret_test — returning a module-GLOBAL struct ident by value // (`return g;`) must copy g's bytes into the return buffer, migrated from // test/wcc/989_globstructret_run.c (F8-c6, #41, #263). The ≤24B register-struct // return path word-copied an N_IDENT source from its BP slot only for a LOCAL // ident; a module-global ident hit no branch (wwstage zero-filled the @retscr, // cstage copied frame garbage), never g(SB). Both stages now copy g's bytes via // the aggregate src-addr memcpy (LEAQ g(SB),SI) and the .s is byte-identical, // so a behavioral @test is the net. Each field is asserted individually so a // dropped / mis-offset word FAILS (a zero-filled @retscr reads back 0). package glob_struct_ret_test; type point = struct { x: i64, y: i64 }; type triple = struct { a: i64, b: i64, c: i64 }; let g16: point = point { x = 3, y = 4 }; let g24: triple = triple { a = 5, b = 6, c = 7 }; fn get16() point = { return g16; }; fn get24() triple = { return g24; }; @test fn ret_16() void = { // rsz 16 register-struct return of a global ident. let p: point = get16(); assert(p.x: i32 == 3); assert(p.y: i32 == 4); }; @test fn ret_24() void = { // rsz 24 register-struct return of a global ident (the third word pins // the full-payload copy). let p: triple = get24(); assert(p.a: i32 == 5); assert(p.b: i32 == 6); assert(p.c: i32 == 7); };