Re: volatile or what? ...

From: Darko M. (
Date: 12/22/03

  • Next message: Paul Pluzhnikov: "Re: Linux glibc clone(2) vs fork(2)"
    Date: 22 Dec 2003 14:52:02 -0800

    > Sounds like you have a variable scope problem. However you have that
    > variable defined, the compiler thinks that the variable is falling out of
    > scope, so the destructor is called. You should look carefully at where your
    > "global" variable is defined, and be sure that you are not dealing with a
    > variable in scope local to the signal handler only.

    I hope I haven't been misunderstood. I sure did declare it globally,
    it is so easy - you just put
    it ouside any function. Therefore I am quite sure that the destructor
    doesn't show up because of
    bad scope analyzis. The thiing is that I am really confused that a
    destructor is called which,
    following all the rules of a good sense, should happen only in
    situations when the given object comes out of scope.

    The thing that was actually supposed to happen is that the global
    variables' contents stay
    untouched after the signal handler exits, even if the signal handler
    explicitly modified those
    variables. I was prepared to that, and ready to use volatile or
    something, but than this happened which, as I said and you have
    noticed, certainly should not be allowed to happen.

    I would appreciate at least an answer saying, for an example, "it is
    up to C++" or "It is up to UNICES memory management" or anything, I
    really don't get it.

  • Next message: Paul Pluzhnikov: "Re: Linux glibc clone(2) vs fork(2)"

    Relevant Pages

    • Re: Returning address of local variable
      ... real-world hardware) to unmap the memory when the variable ... out of scope, the whole concept of destruction is absent from plain C. ... destructor, when a auto storage variable of that type goes out of scope ...
    • Re: Life of a thread
      ... > If a thread goes out of scope and the working proc is done ... Unless, of course, you have unmanaged resources (like a database ... IDisposable and add a ~Destructor to handle all unmanaged ...
    • Re: Overcoming C# limitations
      ... You might as well have defined a CString and have a ... "hidden" destructor as you call it run when the function leaves. ... This would have been useful since I could use this macro in any scope ... knowing that the destructor of MyObj will be called at ...
    • Re: Why no language improvements?
      ... cleanup, then rethrow the exception, you just have the destructor ... cleanup when scope is exited... ... including when due to an exception. ...
    • Re: Is CArray best for this...
      ... CStringWgoes out of scope at function end, the memory is cleaned up by destructor, and so I think that the returned LPWSTR pointer is not valid. ...