Re: Which exception handling system should I use?
Re: Which exception handling system should I use?
- Subject: Re: Which exception handling system should I use?
- From: Brian Stern <email@hidden>
- Date: Tue, 25 Apr 2006 10:21:58 -0400
>If you are using Objective-C++ then there is another minus to @try:
>- marks variables in the subroutine with the @try block as volatile
>block. Why variables are marked as volatile in the first place, I
>have no idea. Maybe someone can explain that.
Some time ago, in the GCC 2.95 days, I worked on a C++ project that had
been developed in CodeWarrior and was being ported to GCC. We discovered a
bug in GCC in code like the following:
SomeClass s = 0;
try {
SomeFuncThatMightThrow();
s = GetAnS();
} catch (...) {
delete s;
}
The GCC optimizer optimized away the initial assignment to zero, presumably
because it thought that s was being assigned to twice in a way that only
the second assignment mattered. So if an exception was thrown before s was
assigned the delete call would crash because s was filled with garbage.
Curiously our work-around was to explicitly mark variables like s as
volatile.
This bug was eventually fixed in later versions of GCC and I can only
assume from your comments that it was fixed by implicitly marking s as
volatile, to inhibit the incorrect optimization. This fix seems like a
hack.
--
Brian Stern
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden