Boost logo

Boost Users :

Subject: Re: [Boost-users] question about boost::thread
From: PingShan Li (lipingshan72_at_[hidden])
Date: 2008-09-15 11:06:12


Thank you for the reply.

This is just a testing program for this question. What you said is that even
the destructor is called for ClassA, and TestClass is out off scope in main
function, the memory for ClassA may still be around and valid on the main
thread's stack. I think I have to agree with you that this is depended on
the compiler. According to C++ standard, "the object no longer exists" once
a destructor is invoked for an object. It depends on how do we understand
this "no longer exists".

>From the C++ standard : (
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2723.pdf)
Once a destructor is invoked for an object, the object no longer exists; the
behavior is undefined if the destructor is invoked for an object whose
lifetime has ended.

On Fri, Sep 12, 2008 at 5:36 PM, Steven Watanabe <watanabesj_at_[hidden]>wrote:

> AMDG
>
> PingShan Li wrote:
>
>> Here is my test program using boost::thread. I would expect this program
>> to
>> crash inside FunctionA because m_ClassA is no longer available.
>>
>> Can anybody help me to understand why it does not crash? thank you.
>>
>>
>
> Incorrect programs are not guaranteed to crash.
> The memory for m_ClassA is on the main thread's
> stack and is almost certain to still be valid (at the
> machine level) when FunctionA is called. In fact,
> depending on your compiler it may not have been
> overwritten at all.
>
> In Christ,
> Steven Watanabe
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



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