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

Use non-throwing new for %new_copy etc #2644

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ojwb
Copy link
Member

@ojwb ojwb commented Jun 24, 2023

This makes the behaviour for C and C++ consistent since now NULL gets returned which gets mapped to Null, None, etc in the target language.

Fixes https://sourceforge.net/p/swig/bugs/1372/

This makes the behaviour for C and C++ consistent since now NULL
gets returned which gets mapped to Null, None, etc in the target
language.

Fixes https://sourceforge.net/p/swig/bugs/1372/
@ojwb ojwb added the C++ label Jun 24, 2023
@wsfulton
Copy link
Member

This is a major API breakage for everyone who expects std::bad_alloc to be thrown and has special exception handling in place to catch this exception. I've put this kind of code in place in a various places.

Alas, the control and handling of out of memory isn't a good story in the generated wrappers. If there are any changes made in this area, it should be part of a comprehensive documented plan for consistency and filling gaps and options for handling non-throwing and throwing new.

@ojwb
Copy link
Member Author

ojwb commented Jun 26, 2023

I've put this kind of code in place in a various places.

It'd be useful to at least document how to do that then.

@wsfulton
Copy link
Member

wsfulton commented Aug 8, 2023

The kind of things I meant is using %exception to catch bad_alloc to handle out of memory in an application specific way by catching the exception, logging it and then mapping it to a particular target language exception. Similarly for throws typemaps which also handle exceptions.

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

Successfully merging this pull request may close these issues.

2 participants