Alloacation on stack inside function

1

Is data allocated on stack inside a function cleared when the function ends? The following code gives me an error (program terminates with 0xC00000FD exception code):

void fun()
{
    const long len = (1024 * 1024) / 4; // 1 MB
    int aa[len]{};
}

int main()
{
    fun();
    const long len = (1024 * 1024) / 4; // 1 MB
    int aa[len]{};
}

If I do not call fun() at the beginning it works fine.

Also, what is a default stack size using MinGW?

c++
memory-management
asked on Stack Overflow Apr 12, 2020 by michalt38 • edited Apr 12, 2020 by michalt38

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0