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

Make accessing single elements in empty parameter vectors return an empty optional #693

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tmadlener
Copy link
Collaborator

BEGINRELEASENOTES

  • Fix small issue in GenericParameters where trying to access a single element of a parameter that was stored as an empty vector resulted in a crash. Instead make this return an empty optional now.

ENDRELEASENOTES

@dirkzerwas this is the fix for the issue in our email discussion.

This seems to be the most reasonable thing to do. The other option would be to return an empty / default constructed value in this case. However, since we introduced the std::optional return type for avoiding exactly that (see #580), I don't think that makes a lot of sense and would make the API inconsistent again.

@tmadlener
Copy link
Collaborator Author

As discussed during the meeting on Nov 5, we will be using an empty optional (as is the current state of this PR at the moment).

Otherwise we run into a read out of bounds in case the parameter is
stored, but with an empty vector value. E.g. from setting it with a
vector that comes from an external source which is empty.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant