Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

struct return

How a large struct comes back from a function - the caller passes a hidden address and the function writes the struct there.

Struct-return (sret) passes the address of caller-allocated result storage as a hidden argument (rdi on System V, rcx on Microsoft x64, a0 on RISC-V; x8 on AAPCS64, not counting as an argument) and returns that address in rax on x86-64; small structs instead come back in registers.

Examples

  • A 32-byte struct returned on x86-64 Linux is written to memory the caller provides, whose address arrives in rdi.

Read the full section →