Re: kernel stack problem

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

On Tue, 2007-04-03 at 21:51 -0400, John Anthony Kazos Jr. wrote:
> > This is wrong. Although the scope is at _block_ level, all variables are
> > allocated on the stack at _function_ level. So, when entering func() all
> > variables within it, including x and y, are allocated.
> But this doesn't make sense. Why would the compiler not immediately 
> optimize both variables into the same allocation? It seems obvious to me 
> that the amount of space pushed onto the stack when the function is 
> entered should be the maximum space needed by any combination of local 
> variables in-scope at any time. GCC wouldn't be that stupid, would it?

Yes, I agree. But take a look...
00:19:01 framos@core2duo:~ $> more teste.c
#include <stdio.h>

int main()
   int x=5;

   printf("addr(x)=%p\n", &x);

      int y=10;
      printf("add(y)=%p\n", &y);

   return 0;
00:19:04 framos@core2duo:~ $> ./teste
00:19:06 framos@core2duo:~ $> 

To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at

[Site Home]     [Audio]     [Hams]     [Kernel Newbies]     [Memory]     [Security]     [Netfilter]     [Bugtraq]     [Photo]     [Yosemite Photos]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linux Resources]     [Fedora Users]

  Powered by Linux