www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/09/05/20:35:30

Xref: news2.mv.net comp.os.msdos.djgpp:8327
From: "Mike Marcelais" <michmarc AT microsoft DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: exception handling
Date: 5 Sep 1996 19:39:19 GMT
Organization: Microsoft Corporation
Lines: 31
Message-ID: <01bb9b62$ae1a9aa0$ba27379d@michmarc2>
References: <mikeday DOT 8 DOT 00040420 AT melbpc DOT org DOT au> <32237837 DOT 794BDF32 AT ift DOT ulaval DOT ca> <32243622 DOT 167EB0E7 AT dra DOT hmg DOT gb> <322C4228 DOT 2781E494 AT dra DOT hmg DOT gb>
NNTP-Posting-Host: 157.55.39.186
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

| 	My problem was with optimisation switches.
| The following definitely works:
| 
| gcc -fhandle-exceptions -o test.exe test.cc -lstdcx
| 
| and so does:
| 
| gcc -O2 -fhandle-exceptions -o test.exe test.cc -lstdcx
| 
| However, the -O3 optimisation switch (which I was using
| by default) breaks the catch mechanism so that
| terminate() is the result of every throw.

From the Gnu C++ documentation on exception handling:

Don't expect exception handling to work right if you optimize, in fact the
compiler will probably core dump. 


You're lucky it works with -O2 at all (and might not if you have a more
complicated program or try and compile it on a more complicated architecture).


-- 
+------------------------+----------------------+
| Mike Marcelais         | Excel Developer and  |
| michmarc AT microsoft DOT com | Magic Rules Guru     |
+------------------------+----------------------+
| Opinions expressed in this post are mine, and |
| do not necessarily reflect those of Microsoft |
+--= Moonstone Dragon =---------------= UDIC =--+ 

- Raw text -


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