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

.end() + 1 #1

Open
GhostCore07 opened this issue Jul 16, 2023 · 1 comment
Open

.end() + 1 #1

GhostCore07 opened this issue Jul 16, 2023 · 1 comment

Comments

@GhostCore07
Copy link

GhostCore07 commented Jul 16, 2023

std::sregex_token_iterator token(s.begin(), s.end()+1, rgx, -1), end;

image

this line is ambiguous it's not clear if end()+1 is undefined behavior, you can find discussions about it going either way, it may or may not be, but it does throw a runtime debug assertion in Visual C++ 2022. Seems like if you need to split on the null-terminator, rather than using the implicit one that string uses you could always explicitly add a '\0' which will get counted as part of the string length (contrary to what strlen would provide).

cheers.

@maronsson
Copy link

I think the s.end() already points to "one after" the last item, so removed +1, which now makes it possible to run/debug the code.
@ProjectPhysX Thanks a lot for this great piece of code!
Have been coding CUDA a bit and now also wanted to try OpenCL, but as many before me has noted, there is more boiler plate code to get a hello-world project running (compare to CUDA).

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