On Sat, 2009-02-28 at 12:06 -0500, me22 wrote: > > GCC allows the Variable Length Arrays feature from C99 in C++ as an extension. > > Consider compiling with -ansi -pedantic > > ~ Scott You can see what the compiler is doing for you if you look at the assembly language. Here is the part where the array gets allocated on the stack (with my comments added): call _ZNSirsERi # cin >> array_size movl -12(%rbp), %eax # load array_size cltq # convert long to quad subq $1, %rax # make sure the new stack addq $1, %rax # pointer meets all the salq $2, %rax # alignment specs. addq $15, %rax addq $15, %rax shrq $4, %rax salq $4, %rax subq %rax, %rsp # allocate the array movq %rsp, -48(%rbp) # and save pointer to it I did this on an x86-64 system in 64-bit mode, and I did not worry through the alignment code to see exactly what's going on. In particular, subq $1, %rax addq $1, %rax is pretty weird. But the real point is where the array gets allocated on the stack. - Bob