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

Calling zim::Search::end() before zim::Search::begin() leads to an infinite loop #463

Closed
veloman-yunkan opened this issue Dec 9, 2020 · 1 comment · Fixed by #530
Closed

Comments

@veloman-yunkan
Copy link
Collaborator

zim::Search::end() returns a meaningful end iterator only if the search object has been properly initialized before that by a call to zim::Search::begin(). As a result, the following code is an infinite loop:

const zim::Search search(archive);
... // initialize the search
const auto endOfSearch = search.end();
for ( const auto it = search.begin(); it != endOfSearch; ++it ) {
}

This is very counter-intuitive, especially given that both zim::Search::begin() and zim::Search::end() are const member functions.

@kelson42
Copy link
Contributor

kelson42 commented Jan 7, 2021

@veloman-yunkan What should be returned to fix that problem? An exception should thrown?

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

Successfully merging a pull request may close this issue.

3 participants