TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Peter Garner
from: David Hooker
date: 1995-01-24 10:48:10
subject: Bug In C-Set++ Exception

PG>   cout << "Start"  << endl ;   // NOT EVEN
THIS LINE IS EXECUTED !!!!!
 PG>                                // THOUGH IT OCCURES BEFORE THE 
 PG>                                // OMINOUS TRY BLOCK

This *should* get executed... 

 PG>     // Oddly, if I used the form 'Test test ()', I got a compiler
error.  This I believe IS
 PG>     // a bug!

BC++ 3.1 for DOS compiles "Test test ()" ok.  However, this is
actually a function declaration
for a function called 'test', taking no parameters, and returning a Test
object.  You should not
have gotten a compiler error until you tried to use test as something other
than a function
name.

As for the exception, when the first throw is encountered, execution jumps to the
catch statement, unwinding the stack as it goes, and calling test's
destructor.  However,
test's destructor throws another X.  Stroustrup doesn't seem to address this issue,
but I believe one of three things could happen:
   1) the second throw is ignored, or
   2) the second throw takes over, and the first throw is ignored, or
   3) the second exception is thrown, and the first is still pending, even after
       the 'catch'.

I tried it with BC++ 1.5 for OS/2, and it seems to do the third scenario(sp?) above.
The catch caught the second exception (from Test's destructor), and the first one
(in the try block) was left unhandled.  My test program terminated with an
"Abnormal program termination", which is what happens on
unhandled exceptions.

I have a test program, if you're interested.

Hope that helps!

-dave-

 * KWQ/2 1.1 * "Press to test."   "Release to
detonate."

--- Maximus 2.02
* Origin: The Dew Line - Grapevine, TX (1:130/24)
SEEN-BY: 12/2442 620/243 624/50 632/348 640/820 690/660 711/409 410 413 430
SEEN-BY: 711/807 808 809 934 942 949 955 712/515 713/888 800/1 7877/2809
@PATH: 130/24 22 124/4115 1 396/1 3615/50 105/103 42 724/13 600/500 2 82 229/2
@PATH: 12/2442 711/409 808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.