|
Boost Users : |
From: Peng Yu (pengyu.ut_at_[hidden])
Date: 2007-10-16 16:24:52
On 10/16/07, Mike Marchywka <marchywka_at_[hidden]> wrote:
>
> >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?
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net