Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix throwing nil exceptions. #4

Merged
merged 3 commits into from
Sep 7, 2015
Merged

Conversation

ngrewe
Copy link
Member

@ngrewe ngrewe commented Sep 7, 2015

The following is perfectly legal on Mac OS X:

@try
{
  @throw(nil);
}
@catch (id obj)
{
  printf("Caught: %p", obj);
}

It doesn't work presently because we were trying to dereference the object pointer to determine the class.

{
assert(nil == x);
caught_exception = YES;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the correct behaviour for, throwing nil and catching (for example)NSObject *? Should nil also be caught by void* catches in Objective-C++ (this case used to crash the Apple runtime, not sure if they've fixed it now)?

@ngrewe
Copy link
Member Author

ngrewe commented Sep 7, 2015

What's the correct behaviour for, throwing nil and catching (for example)NSObject *?

It is only caught by @catch(id) and @catch(...), not by any other interface type. I've added a few more tests for those cases, but I'm running into some weird behaviour here: The standalone test case passes, but similar code, linked against gnustep-base doesn't work (i.e. @catch(NSObject*) catches nil as well…)

Should nil also be caught by void* catches in Objective-C++ (this case used to crash the Apple runtime, not sure if they've fixed it now)?

I've checked and it's not caught by a void* handler on 10.10.5 (it doesn't crash either, fwiw).

@davidchisnall
Copy link
Member

The stand-alone code may be interacting oddly with the CXXException.mm stuff in -base, which attempts to box C++ exceptions as Objective-C objects. We should probably remove that now - it was largely a work-around for the fact that we didn't have working Objective-C++.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants