AnsweredAssumed Answered

Destructor isn't executed when stepping over closing brace?

Question asked by lekigo on Mar 19, 2010

Hi.

I have faced with some problem. When "stepping over" closing brace of block, where object was created, the destructor isn't executed.

The situation:

{

    TCritSect cs;

    ...//some instructions

} <--stepping over this brace causes this behavior


Class TCritSect is defined as follows:

class TCritSect

{

public:

    TCritSect () //disables interrupts, save IMASK

     {

         StatusReg = cli();

     };

    ~TCritSect() //restores IMASK

     {

         sti(StatusReg);

     };

private:

    volatile unsigned int StatusReg;

};

 

Skipping of destructor leave interrupts disabled. When "stepping into" on the closing brace the debugger goes to destructor, executes it and interrupt are reenabled.

Outcomes