Variables local to a scope are normally destroyed at the end of a statement block. The lifetime of the object is also over, meaning that the stack is popped and memory is physically returned to some sort of pool, or the operating system (whatever the case may be.)
The only real difference a static variable has from a normal variable is that the lifetime of the variable doesn't end with its' scope, it's value still exists somewhere in memory. When you first call a function with a static variable, the initialization will be performed, but performed not again if the function is recalled. Access is also restricted to places where you can give that value a name.
It's up to compiler implementors to implement this behavior. I suppose a lot of things could work, like copying a static variable off the stack and silently moving it elsewhere when it's scope has ended. But it's most likely kept in the same memory globals are, as this is possible:
Code:
#include <stdio.h>
#include <assert.h>
void funcio( void );
int * p;
int main ( )
{
funcio();
assert( *p == 42 );
return 0;
}
void funcio ( void )
{
static int d = 42;
p = &d;
}
[edit] Oh and, also, the name of a static variable is included in the compiler's symbol table when you build. That's how it remembers what the "special" value is, even if you have another variable with different lifetime semantics. [/edit]
Clearer now?