> Which compiler from this century doesn't allocate stack space
> independent from the source order?

At a minimum, the one that shipped with 5.2.  According to --version,
it is

gcc (GCC) 4.1.3 20080704 prerelease (NetBSD nb3 20111107)

which is well within this century, and, on amd64, this program

        #include <stdio.h>
        
        int main(void);
        int main(void)
        {
         volatile char beg;
         volatile char a;
         volatile int b;
         volatile char c;
         volatile char end;
        
         a = 1;
         b = 2;
         c = 3;
         printf("%d\n",(int)(&beg-&end));
         return(0);
        }

prints 9, but if I move the "volatile int b" line up or down one line,
the output changes to 8 or 10.  (Yes, the I got the beg and end names
backwards.)  The volatiles and assignments are to keep the compiler
from optimizing unused variables out of existence - the first version,
which had neither, printed 1.  Compiling with -save-temps and looking
at the assembly, it's clear that the variable order on the stack is the
source-code order.

/~\ The ASCII                             Mouse
\ / Ribbon Campaign
 X  Against HTML                mo...@rodents-montreal.org
/ \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

Reply via email to