[cfe-dev] returning in @finally block swallows exception throwing.

Hoon Hwangbo drawtree at me.com
Sat Aug 11 12:13:53 PDT 2012


Hi. I discovered soe weird behavior. If the code `return` in @finally block, it swallows exceptions.
Here's full source code I tested with.

#import <Foundation/Foundation.h>

int main (int a, char** b)
{
    @try
    {
        NSLog(@"trying something...");

        @try            { @throw @"AA"; }
        @catch (...)    { @throw;       }
        @finally        { return 0;     }
    }
    @catch (...)
    {
        NSLog(@"something catched.");
    }
    @finally
    {
        NSLog(@"finally...");
    }
}

IMO, internal exception should be caught at external @catch, but actually it doesn't.
Can I know the exact behavior of `return` in @finally block?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120811/8c4cd51e/attachment.html>


More information about the cfe-dev mailing list