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

Add a check for begin == end to allow users to supply an empty list to lockfree::stack::push #21

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

Conversation

cdglove
Copy link
Contributor

@cdglove cdglove commented Feb 19, 2016

I'm not 100% sure if this is desirable or not. A simple test is something like this;

#include <boost/lockfree/stack.hpp>

int main()
{
    boost::lockfree::stack<int> s(10);
    std::vector<int> v;
    s.push(v.begin(), v.end());
    return 0;
}

This will crash (in debug at least), when dereferencing the begin iterator. However, it's possible this is as designed because it's expected that the user doesn't supply an empty list. I'm OK with either, but did hit this today.

@timblechmann
Copy link
Collaborator

needs a test, will look into it

@cdglove
Copy link
Contributor Author

cdglove commented Jun 11, 2016

It's a question of if we want to impose the check on all callers even if they know for sure that their list is not empty. It might be a bit pessimistic to put the check inside push because then everyone pays for the cost of the branch. An ASSERT might also be acceptable.

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.

2 participants