Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Trouble with C++ exceptions



Hi,

I'm trying to catch an exception using a set_terminate handler, which
re-throws the exception and tries to catch it using a number of
templates, including "...". On Linux, this works fine; on OS X, the
handler gets stuck in an endless recursion, re-throwing the exception
and being called over and over again.

I've attached the problematic isolated code; the output is as follows:

On OSX 10.2.6, gcc 3.1 20020420 (prerelease):
$ gcc -o testprogram Main.cc -lstdc++
$ ./testprogram
Re-throwing.
Re-throwing.
Re-throwing.
[... etc until the stack overflows]

On Linux 2.4.19, gcc 3.2:
$ gcc -o testprogram Main.cc -lstdc++
$ ./testprogram
Re-throwing.
MyException
Aborted

So Linux does the right thing. Is this a known bug, and is there
perhaps a patch available? I'm porting a fairly large app that has this
sort of thing all over, and I don't really want to either delete all
throw() clauses or declare all possible exceptions.

Thanks in advance,
--Bjvrn

[demime 0.98b removed an attachment of type application/octet-stream which had a name of Main.cc]
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.