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

UB in std::views::split #1810

Open
OptimumCpp opened this issue Feb 9, 2024 · 7 comments
Open

UB in std::views::split #1810

OptimumCpp opened this issue Feb 9, 2024 · 7 comments

Comments

@OptimumCpp
Copy link

This must actually become a std DR; but since you're the godfather of std::ranges, I bring my complaining to you. This is the original post pointing out the problem.

@haleyk10198
Copy link

haleyk10198 commented Apr 12, 2024

it's NAD. author was actually searching with "\0" inclusively.

on that note, i'd agree it's a surprise to developers and debatable whether we should have a specialization of std:;ranges::end for char arrays, but would require some expertise to verify if it breaks any other STL algorithms

@OptimumCpp
Copy link
Author

OptimumCpp commented Apr 12, 2024 via email

@OptimumCpp
Copy link
Author

OptimumCpp commented Apr 12, 2024 via email

@haleyk10198
Copy link

range-v3 has ranges::view::c_str for developers to express the context in null-terminated string, which is effectively std::string_views. code works as trivially intended when the pattern is wrapped by them.

To remove ambiguity you'd need to delete std::ranges::end for char[]. doing that will break and surprise a lot of generic code that is working with T[ ]. It will be hard to convince ISO to change the convention a breaking way.

@OptimumCpp
Copy link
Author

OptimumCpp commented Apr 12, 2024 via email

@haleyk10198
Copy link

That will do no good but break a jaw dropping amount of code.

A better place for these changes should be compiler warnings, that would still keep developers away from surprises without breaking anything.

@OptimumCpp
Copy link
Author

OptimumCpp commented Apr 13, 2024 via email

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

No branches or pull requests

2 participants