C++/CLI quiz: What is the exact callstack?

I have a small quiz:
Here is a small code, compiled with “/clr” (this is important).
Can you tell me, what is the exact callstack inside the method “Foo”?
(And how can you prove this)

struct V
{
  V() {}
  V(const V &v) 
  {
    this->i = v.i;
  }
  int i;
};
 
class C
{
public:
  void CallFoo()
  {
    V v;
    Foo(v);
  }
  virtual void Foo(V v)
  {
    // TODO: What is the callstack!?
  }
};
 
int main()
{
  C c;
  c.CallFoo();
}

Any hints can be posted as comments.
By the way: VS208 does not show you the exact callstack, but it gives you a hint, that there is something that you do not see ;)

4 Responses to “C++/CLI quiz: What is the exact callstack?”

  1. tom Says:

    Interesting,

    The /clr version creates one more V temp instance than that without the switch.

    Did you find out why?

  2. Ben Voigt [C++ MVP] Says:

    The question is where the native->managed transition takes place. Or did you not want the entire call stack, all the way back to the native entry point which Windows places in the instruction pointer of the context of the first thread of your new process before making it runnable?

  3. Jochen Kalmbach’s Blog » Blog Archive » C++/CLI quiz: Answer Says:

    […] one of my last post, I asked the question, how does the callstack look like. It was is simple unmanaged class with a […]

  4. jkalmbach Says:

    Thanx for all comments. Here is the answer:
    http://blog.kalmbach-software.de/2009/05/12/ccli-quiz-answer/

Leave a Reply