Since a
is implicitly auto
(i.e. is not extern
or static
) it is stored in the call stack frame.
In fact, the compiler may optimize that: probably, in your case, when optimizing, it will stay in a register (or be constant propagated and constant folded): no need to allocate a call stack slot for your a
This is of course compiler, target platform, and operating system dependent. For the GCC compiler, understand the Gimple internal representation (thru -fdump-tree-all
, or using the MELT probe) and look at the generated assembler code (use -fverbose-asm -S -O
)
See also this answer which gives a lot of references.
GCC 4.8 on Linux/x86-64 compiles (with gcc -S -fverbose-asm -O
) your function into:
.globl func
.type func, @function
func:
.LFB0:
.cfi_startproc
movl $7, %eax #,
ret
.cfi_endproc
.LFE0:
.size func, .-func
So you see that in your particular case no additional space is used for 7
, it is directly stored in%eax
which is the register (defined in the ABI conventions) to hold its returned result.
The value 7
is stored in the machine code, inside the movl
machine instruction. When func
is executed, that 7 is loaded into register %eax
containing the returned result of func
.