Re: stack allocation and gcc
From: Ihar 'Philips' Filipau
Date: Wed Mar 10 2004 - 10:07:38 EST
Richard B. Johnson wrote:
The caller expects that the space for the second set of local
variables in the second program unit is not allocated until the
program unit is entered.
I don't know why he would expect this behavior. Certainly
It was my first thought actually - when I have started typeing in
e-mail.
When I have reached half e-mail - I have understood that this is
simple performance consideration - stack space is allocated once.
I have tryed to convert my e-mail to another issue - but seems I did
it not good enough :-)
But then I realized that my thinking was wrong - I'm using variables
in different never overlapping contextes. But space allocated for
everyone. "if (..) { int i; }; if (...) { int i; }" will result not in
sizeof(int) stack space allocated - but in sizeof(int)*2.
It seems that gcc check size required by all top level contextes in
function - it checks for "if { int a[16] } else { int a[16] }" - space
allocated correctly.
But 'if () { int a[16]; }; if () { int a[16] };' seems to break
something, and sum of the sizes for both if()'s spaces finishes
allocated on stack. And this was the case with macro in my module.
I doubt I can write competent report/query to gcc mail list -
probably it is worth to ask there.
--
Ihar 'Philips' Filipau / with best regards from Saarbruecken.
-- _ _ _
"... and for $64000 question, could you get yourself |_|*|_|
vaguely familiar with the notion of on-topic posting?" |_|_|*|
-- Al Viro @ LKML |*|*|*|
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/