This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Strange behaviour of gcc


fabrizio_ge-wolit@tiscali.it wrote:
> Can somebody explain why gcc (version 3.2 20020927) on Cygwin does
> this? Type this simple C program
>
> void func(void){
>   struct {unsigned char data[3985];}var;
> }
>
> and compile with
>
> gcc -c filename.c
>
> Then type
>
> nm filename.o
>
> The output is
>
> 00000000 b .bss
> 00000000 d .data
> 00000000 t .text
>          U __alloca
> 00000000 T _func
>
> Why on earth is the symbol __alloca doing there?
>
> Just change the program to
>
> void func(void){
>   struct {unsigned char data[3984];}var;
> }
>
> and compile it. This time, nm's output is
>
> 00000000 b .bss
> 00000000 d .data
> 00000000 t .text
> 00000000 T _func
>
> as it should. Is there a reason why the symbol __alloca appears?

Yes. Gcc's optimizer chose to make a large amount of local variable
allocation into an alloca call.

Does it matter?

Max.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]