This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
problem with exceptions on egcs1.1.2
- To: cygwin at sourceware dot cygnus dot com
- Subject: problem with exceptions on egcs1.1.2
- From: Christophe Trophime <trophime at labs dot polycnrs-gre dot fr>
- Date: Wed, 06 Oct 1999 11:32:35 +0100
- Organization: LCMI CNRS
- Reply-To: trophime at labs dot polycnrs-gre dot fr
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.
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@polycnrs-gre.fr
adr;quoted-printable:;;25, Av des Martyrs=0D=0ABP 66;Grenoble;;F-38042;France
fn:Trophime Christophe
end:vcard
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com