www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/04/15:46:21

From: igp AT vlc DOT servicom DOT es (Ignacio García Pérez)
Newsgroups: comp.os.msdos.djgpp
Subject: Help!!!, using exceptions.
Date: Fri, 04 Sep 1998 19:45:41 GMT
Organization: GND
Lines: 43
Message-ID: <35f041dc.1315962@MERCURIO>
Reply-To: igp AT vlc DOT servicom DOT es
NNTP-Posting-Host: rdsi5.vlc.servicom.es
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi, 

I just began today my very-first-stupid-program in C++ using
exceptions. I so simple just to check that the exception handling
mechanism is working.

Well, it doesn't work. I compiled it using GCC 2.81, compiles with no
complaints but when I execute it, exits with an "Abort!" message when
the exception is thrown:

#include <stdio.h>

void Test(int E) {
	puts("Test-BEGIN");
	if (E) throw (E);
	puts("Test-END");
	}

void main(void) {

	puts("main-BEGIN");

	try { Test(1); }

	catch (int E)	{ puts("catch (int E)");    }
	catch (...) 	{ puts("catch (...)");      }

	puts("main-END");
	}

The output is:
"main-BEGIN"
"Test-BEGIN"
"Abort!"


As you can see, even if I was doing something wrong that caused the
integer exception not to be caught by the first "catch" block, the
next "catch(...)" should catch ALL exceptions.

Any clues will be greatly appreciated.

Thanks. Nacho.

- Raw text -


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