简体   繁体   中英

stack dynamic and stack dynamic array

How C/C++ compilers handle fixed stack dynamic and stack dynamic arrays. I saw how static variables are different from stack dynamic variables by looking at the addresses of these variables in the assembly code.

As said in a remark stack dynamic arrays from the C++ standard.

When there is no local/stack dynamic array the place of each local variables in the stack is a constant offset in the frame associated to the current function

When a dynamic array is introduced among local variables the compiler has to take into account the size used for the array to access to the local variables placed 'after' the array to add it at the constant offset without it. For that we can easily imagine the size/number of elements is also placed in the stack 'before' the array allowing the generated code to read it to make the offset computations. So clearly a dynamic array has an impact on the performances

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM