You code:
void fn(int a[3])
{
a[5]=5;
}
Is equivalent to code:
void fn(int* a)
{
a[5]=5;
}
Fortunately you can check it by by compile your code with -S
option to gcc (or g++).
You will get same assembly output for Both: (output file will be with .s
extension)
fn:
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %eax // base address assign to eax register.
addl $20, %eax // a[5] , because 5*4 = 20, so eax = eax + 20
movl $5, (%eax) // this is =5 , (%eax) = 5
popl %ebp
ret
.size fn, .-fn
.section .rodata
Both Code use only base address pass to the fu()
function.
there is nothing about size 3 of argument