Extra space allocated for array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When I simply allocate a two hundred byte array:

int main(void)
{
    int myArray[50];

    myArray[0] = 123;
    myArray[6] = 456;
    myArray[49] = 789;

    return 0;
}

gcc allocates sixteen extra bytes:

main:
	pushq	%rbp
	movq	%rsp, %rbp
	subq	$88, %rsp
	movl	$123, -208(%rbp)
	movl	$456, -184(%rbp)
	movl	$789, -12(%rbp)
	movl	$0, %eax
	leave
	ret

Notice that it leaves 8 bytes "above" where the caller's rbp is stored
and the final 8 bytes of the red zone are unused. There seems to be an
8-byte buffer at both ends of the array. Why?

-- Bob



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux