Idov
Idov

Reputation: 5124

Weird difference in callstack between release and debug

I'm trying to walk the stack of this sample program:

#include <windows.h>

void Func1()
{
    Sleep(1000);
}

void Func2()
{
    Sleep(1000);
    Func1();
}

void Func3()
{
    Sleep(1000);
    Func2();
}

void main()
{
    for (int i = 0; i < 100; i++)
    {
        Func3();
    }
}

In debug mode I get what you'd expect. Something like:
Sleep
Func3
main

In release mode (with frame pointer optimization enabled) I get the stack:
Sleep
main

Where did the function between "main" and "sleep" go in the release run?

Upvotes: 2

Views: 221

Answers (1)

Idov
Idov

Reputation: 5124

The function was inlined.
I simply change the "Inline Function Expansion" to Only_inline (in VS2008) and the missing function appears. :)

Upvotes: 2

Related Questions