Add precondition that pointers point to structs in the object factory #4483
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've been trying to find out what kinds of exprts can be passed to the object factory, and in the case of pointers, the only two cases that appeared in the code were pointers to structs and pointers to
void*
. The latter had a comment saying that it applies to#exception_value
s, which according to @smowton have been replaced.I tried adding a precondition that pointers always point to structs, ran most of the tests locally and haven't found any failures yet. So I am assuming that it is now safe to make this change.
I would like to do some refactoring for the struct case in follow-up PRs, so if reviewers think that there is any way that a pointer could still end up in the object factory and point to something other than a struct, please let me know and I will close this PR and instead add a test for this case.