• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Which exception handling system should I use?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Which exception handling system should I use? (From: Matteo Manferdini <email@hidden>)
 >Re: Which exception handling system should I use? (From: Ondra Cada <email@hidden>)
 >Re: Which exception handling system should I use? (From: Derrick Bass <email@hidden>)

  • Prev by Date: Re: Temporary object created at runtime with Core Data
  • Next by Date: Re: Temporary object created at runtime with Core Data
  • Previous by thread: Re: Which exception handling system should I use?
  • Next by thread: Re: Which exception handling system should I use?
  • Index(es):
    • Date
    • Thread