Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Unused Static Stack Varibles

Name: Anonymous 2009-10-31 1:48

Hey /prog/,

In C, are variables located in the stack recycled/freed when they are no longer needed? I suppose that this depends on the compiler, but does anyone know if GCC does this?

To be a little clearer, let's say I have these two translation units...

main.c/.h
settings.c/.h

main() calls the function get_settings() (located in settings.c) which will fill the variables (located in main.c) with data read from a file and then returns.

Since there is no longer any purpose for the staic variables declared in settings.c, are they freed once get_settings() returns?

Name: Anonymous 2009-11-01 1:08

>>39
The GLOBL section is hardly the heap, bro.

Name: Anonymous 2009-11-01 2:47

>>39
They aren't on the heap.

Name: Anonymous 2009-11-01 3:09

I'm getting the feeling that WHBT

Name: Anonymous 2009-11-01 3:24

>>40
What don't you understand about that statement?

C:
{
  a = 1;
}
{
  b = 2;
}

//A fictional(a real compiler may remove (dead code elimination)that exact code since it isn't used) compiler may translate it to something like this:
mov edx,1 ; allocs edx to be used for a
mov edx,2 ; a is out of scope, allocs edx to be used for b

Name: Anonymous 2009-11-01 3:58

oops, forgot to declare the variables:
{int a; a = 1;} {int b; b = 1}

Name: Anonymous 2009-11-01 4:02

>>44
ur code tells me that your gay.

Name: Anonymous 2009-11-01 5:12

>>46
Well ur mr gay.

Name: Anonymous 2009-11-01 8:24

>>44
Can u explain further?  I don't understand how it is that the compiler is smart enough....

Another example would be good, perhaps a bit longer this time???

thx!

Name: Anonymous 2009-11-01 8:45

>>48
Smart enough? Let's say you have a pool of usable registers, for the variable `a', the compiler assigns one register (edx), and after `a' becomes out of scope, the register(edx) becomes free to be used for another variable, in which case it assigns it to b. This was just an example. Go read the dragon book or some other book on compiler design. Or if you can't be bothered to read some proper literature, http://en.wikipedia.org/wiki/Register_allocation

Name: Anonymous 2009-11-01 8:48

>>48
okay lesson one
in computer numbers are binary
so they are liek 010011101003010
or they are like adbagcbf then they are haxadecimal
you may also say 0xnumber to be hax
but they are harder so you must binary
so computer goes faster (no translate time)
you may also use other languages because
what i said is assembler what computer speaks you have to use assembler but can use other languages
like c (with the ++ extension maybe for serious programing) or pascal or javascript (java in short) or maybe haskell but i dont understnad it it has no loops so i dont konw how it works you cant code with no loops
get it so far?

Name: Anonymous 2009-11-01 10:55

>>49-50
YHBTFS

Name: Anonymous 2009-11-01 11:08

>>51
Not programming related.  Fuck you, you fucking normalfag piece of shit niggerfuck fucktard spammer.

Name: Anonymous 2009-11-01 11:11

>>49
Have any recommendations for reading on compiler design?

Name: Anonymous 2009-11-01 11:14

>>54
Is using google that hard?

Compilers: Principles, Techniques, and Tools
Modern Compiler Implementation in ML
Advanced Compiler Design and Implementation

Name: Anonymous 2009-11-01 11:19

How about just reading the Anonix C Compiler's source code?

Name: Anonymous 2009-11-01 12:22

COCK MY ASS

Name: Anonymous 2011-02-03 6:27

Name: Anonymous 2013-01-18 23:46

/prog/ will be spammed continuously until further notice. we apologize for any inconvenience this may cause.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List