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 😉
Interesting,
The /clr version creates one more V temp instance than that without the switch.
Did you find out why?
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?
Pingback: Jochen Kalmbach’s Blog » Blog Archive » C++/CLI quiz: Answer
Thanx for all comments. Here is the answer:
http://blog.kalmbach-software.de/2009/05/12/ccli-quiz-answer/