delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/10/06/05:30:16

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT sourceware DOT cygnus DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
Message-ID: <37FB2543.AF3F9542@polycnrs-gre.fr>
Date: Wed, 06 Oct 1999 11:32:35 +0100
From: Christophe Trophime <trophime AT labs DOT polycnrs-gre DOT fr>
Reply-To: trophime AT labs DOT polycnrs-gre DOT fr
Organization: LCMI CNRS
X-Mailer: Mozilla 4.7 [en] (WinNT; I)
X-Accept-Language: en,fr,fr-CH,fr-CA
MIME-Version: 1.0
To: cygwin AT sourceware DOT cygnus DOT com
Subject: problem with exceptions on egcs1.1.2

--------------B1F89E31F84448D32FD2528B
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I am currently using B20.1 and egcs1.1.2. I am trying to port on NT4 a
code developped on SGI which uses exceptions.
I have some problems with exception.

I tried this simple example :

include <strings.h>
#include <stdlib.h>

#include <iostream.h>
#include <iomanip.h>
#include <fstream.h>

class File_Exception{
       public :
        char * filename;
  char * status;
        File_Exception(const char *msg) {
                        filename = new char [strlen(msg)+1];
         strcpy(filename, msg);
   status = NULL;
        };
        virtual ~File_Exception() {
     cout << "File_Exception Destructor : " << filename << " " << status
<< endl << flush;
     delete[] filename;
     delete[] status;
  };
  virtual void debug_print(){
     cerr << "File_Exception : ";
     cerr << filename << " " << status;
     cerr << endl << flush;
  };
  void set_status(const char * _thestatus){
                   status = new char[strlen(_thestatus)+1];
     strcpy(status,_thestatus);
  };

};
class File_NotFound : public File_Exception{
       public :
        File_NotFound(const char *msg) : File_Exception(msg) {
     File_Exception::set_status("file not found");
                };

};

class SimpleReader
{
   protected:

      char *                           filename;
      ifstream *                            str;

   public:

      // Constructors and Destructor

      SimpleReader(char * name)
      {
         filename = new char[strlen(name)+1];
         strcpy(filename, name);

         str = new ifstream(filename, ios::in|ios::nocreate);
      };

     virtual ~SimpleReader(){
        str->close();
        delete str;
        delete[] filename;
     };

     void init(){if (str->fail()) throw File_NotFound(filename);};

};

int main(int argc, char *argv[])
{
 int result = 0;
 SimpleReader * psr = new SimpleReader(argv[1]);
 try {
    psr->init();
 }
 catch(File_Exception & msg){
      msg.debug_print();
      result=1;
 }

 delete psr;
 return result;
}

It works fine on SGI (using either gcc 2.8.1 or Mipspro 7.20) but
it gives me the following error message with egcs1.1.2 :

File_Exception Destructor : C++_loops_elma file not found
File_Exception : ?"A
File_Exception Destructor : ?"A
[main] D:\Users\Trophime\Thelma\usr\test_exceptions.exe 2784 (0)
handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
[main] test_exceptions 2784 (0) handle_exceptions: Dumping stack trace
to test_exceptions.exe.core

The exception is deleted before it is caught by my handler which is not
the case on SGI.

Do I make something wrong?
Is there a work around to make exception working?
Or should I consider upgrade to GCC2.95?

Thanks for help.

--------------B1F89E31F84448D32FD2528B
Content-Type: text/x-vcard; charset=us-ascii;
 name="trophime.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Christophe Trophime
Content-Disposition: attachment;
 filename="trophime.vcf"

begin:vcard 
n:Christophe;Trophime
tel;fax:+33 4 76 85 56 10
tel;work:+33 4 76 88 90 02
x-mozilla-html:FALSE
org:CNRS;LCMI
version:2.1
email;internet:trophime AT polycnrs-gre DOT fr
adr;quoted-printable:;;25, Av des Martyrs=0D=0ABP 66;Grenoble;;F-38042;France
fn:Trophime Christophe
end:vcard


--------------B1F89E31F84448D32FD2528B
Content-Type: text/plain; charset=us-ascii

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
--------------B1F89E31F84448D32FD2528B--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019