Skip to content

Wrong range in [alg.search] LWG4179 #7474

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

Closed
slotosch opened this issue Dec 5, 2024 · 7 comments
Closed

Wrong range in [alg.search] LWG4179 #7474

slotosch opened this issue Dec 5, 2024 · 7 comments
Labels
lwg Issue must be reviewed by LWG.

Comments

@slotosch
Copy link

slotosch commented Dec 5, 2024

During the qualification of the C++ STL Validas has pointed me to the following issue:
The specification of [alg.search] has a wrong range.
Currently the range is "[first1, last1 - (last2 - first2))" (exclusive) but should be "[first1, last1 - (last2 - first2)]" (inclusive).
So please correct the closing ")" to "]". Otherwise the last occurence will not be found.
We observed the issue in C++14 and C++17 and cppreference.com
The implementations do the right thing and work correctly and find even the last occurence.

For example in the list {1, 2, 3, 4, 5} the pattern {4,5} should be found (obviously).
In the case the last element is not included it will not be found.
The attached programm shows that the implementation is working and find the pattern.
rangebug.cpp.txt

@tkoeppe
Copy link
Contributor

tkoeppe commented Dec 5, 2024

This does not sound editorial to me: https://github.com/cplusplus/draft/wiki/How-to-tell-if-an-issue-is-editorial

Do you think it is?

@slotosch
Copy link
Author

slotosch commented Dec 5, 2024

This does not sound editorial to me: https://github.com/cplusplus/draft/wiki/How-to-tell-if-an-issue-is-editorial

Do you think it is?

Indeed this is semantic issue. Sorry if I have misclassified it. But I do not consider this a semantic extension request. It's a simple bug, obviously, since {4,5} should be findable in {1,2,3,4,5}. The implementation is correct.

@jwakely
Copy link
Member

jwakely commented Dec 5, 2024

@slotosch
Copy link
Author

slotosch commented Dec 5, 2024

Please see https://cplusplus.github.io/LWG/lwg-active.html#submit_issue instead

Thanks for the hint Jonathan, I send you an email with the description.
Hopefully it arrived

@jwakely
Copy link
Member

jwakely commented Dec 6, 2024

Got it, thanks

@jensmaurer jensmaurer added the lwg Issue must be reviewed by LWG. label Dec 6, 2024
@slotosch
Copy link
Author

slotosch commented Dec 7, 2024 via email

@Dani-Hub
Copy link
Member

Dani-Hub commented Dec 7, 2024

The library issue exists now, see LWG 4179.

@jensmaurer jensmaurer changed the title Wrong range in [alg.search] Wrong range in [alg.search] LWG4179 Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lwg Issue must be reviewed by LWG.
Projects
None yet
Development

No branches or pull requests

5 participants