On 10/16/07, Mike Marchywka
reseting shared_ptr with an array from the stack is not defined? Or it is defined and shared_ptr can figure out it is from the stack and do not delete it?
Try to pass "a" to a boost::shared_ptr<int> that isn't on the stack and try it :) You may just be lucky this gets popped while "a" is still there. Is that your question?
I'm not talking about whether shared_ptr is in the stack or not. I'm talking about 'a'. In my example, 'a' is in the stack, I pass its address to reset shared_ptr. I'm asking whether this is legal code, that is to ask whether the behavior is defined. Or the program does not crash is just because I'm lucky, but it may crash in other platform or for the binary code generated from other compiler?