Destructor causes compiler error with hard exit?

This is a discussion on Destructor causes compiler error with hard exit? within the C++ Programming forums, part of the General Programming Boards category; If I hard exit the debug version of my exe, I get a compiling error from class destructors that havn't ...

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    18

    Destructor causes compiler error with hard exit?

    If I hard exit the debug version of my exe, I get a compiling error from class destructors that havn't been called yet. Does this mean I have built the destructors wrong, or is it normal because the program quit before the destructor would have been called under normal conditions?

    Code:
    class Class
    {
    private:
    int x;
    int y;
    
    public:
    Class()
    {
     x = 0;
     y = 0;
    }
    ~Class(){}
    
    };
    That's the basic form of my classes.

  2. #2
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,295
    Any error that occurs after your program starts is a run-time error, not a compile-time error.
    You haven't described what you mean by "hard exit".
    There is nothing in such a simple mocked up code snippet that tells us anything remotely useful.

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    18
    Quote Originally Posted by iMalc View Post
    Any error that occurs after your program starts is a run-time error, not a compile-time error.
    You haven't described what you mean by "hard exit".
    There is nothing in such a simple mocked up code snippet that tells us anything remotely useful.
    If I close the debug version of my .exe by literally closing(x) the window. My compiler says there was an access violation. This only happens if there are destructors that would have been called had the program ended on its own terms.

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,445
    Post the smallest and simplest compilable program that demonstrates the problem.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,295
    I would not call that a hard exit. I would call that simply closing the app.

    If I was going to use the term "hard exit", I would use it to mean directly "terminating the process".
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. how to call a compiler?
    By castlelight in forum C Programming
    Replies: 3
    Last Post: 11-22-2005, 10:28 AM
  3. Replies: 2
    Last Post: 07-06-2005, 07:11 PM
  4. Compiler Design... Anyone That Can Help!
    By ComputerNerd888 in forum C++ Programming
    Replies: 3
    Last Post: 09-27-2003, 09:48 AM
  5. Replies: 5
    Last Post: 02-08-2003, 06:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21