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

reader::filter can't handle two excludes of the same length #21

Closed
DefaultRyan opened this issue May 5, 2021 · 0 comments · Fixed by #22
Closed

reader::filter can't handle two excludes of the same length #21

DefaultRyan opened this issue May 5, 2021 · 0 comments · Fixed by #22

Comments

@DefaultRyan
Copy link
Member

The comparison predicate in reader::filter is attempting to order items in descending order of string length, and breaks ties by putting the true booleans before the false booleans.

The problem is that the predicate is ill-formed. A comparison predicate should always return false for compare(a, a) and should return false for at least one of compare(a, b) and compare(b, a). To put it another way, if compare(a, a) ever returned true, or compare(a, b) and compare(b, a) both returned true, you have an ill-formed predicate.

The filter predicate gets into this situation when there are two entries in exclude with the same string length, causing misbehavior in release and an assert in debug.

The predicate to sort needs to be updated from

return (size_compare > 0) || ((size_compare == 0) && !lhs.second);

to

return (size_compare > 0) || ((size_compare == 0) && lhs.first && !lhs.second);
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 a pull request may close this issue.

1 participant