C array size given by variable

后端 未结 2 581
[愿得一人]
[愿得一人] 2020-12-02 02:23

I found some code today that confused me. It did something like this:

#include 

int main(int argc, char **argv) {
    int x = 5;
    int foo         


        
2条回答
  •  猫巷女王i
    2020-12-02 02:47

    The array foo is on the stack so how could it be expanded by x?

    gcc simply moves the stack pointer:

    subq    %rax, %rsp
    

    Link to full example with assembly output

提交回复
热议问题