This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: FreeBSD/GCC Oddness.
- From: Oscar Fuentes <ofv at wanadoo dot es>
- To: gcc-help at gcc dot gnu dot org
- Date: Sat, 24 May 2003 12:47:32 +0200
- Subject: Re: FreeBSD/GCC Oddness.
- Cancel-lock: sha1:W+SVjtRoCftbl6M8Cxj85jz1YGA=
- References: <3ECF4AEE.30007@cmc.optus.net.au>
Chris Keladis <chris@cmc.optus.net.au> writes:
> Hi folks,
>
> On a FreeBSD 4.8-RC box with "gcc version 2.95.4 20020320 [FreeBSD]" i
> have a question with how the compiler computes the space for local
> variables on the stack.
>
> Using the following sample code.
>
>
> /* dummy program */
>
> int func(void)
> {
> int i;
>
> return(0);
> }
>
> int main(void)
> {
> func();
>
> return(0);
> }
>
>
> Generates the following prologue (for func()) in GDB
>
> 0x804846c <func>: push %ebp
> 0x804846d <func+1>: mov %esp,%ebp
> 0x804846f <func+3>: sub $0x18,%esp
>
>
> Why is 0x18 subtracted instead of 0x4? Alignment, performance? A
> RedHat box with the same code sub's 0x4.
Was the same gcc version, with the same switches?
> I was wondering if some kind soul could enlighten me on the reason
> for this?
Maybe (non)optimization has something to do with it. Try -O2 or -O3
and most likely you will obtain a dramaticall change for produced
code.
--
Oscar