OpenCL-Wrapper icon indicating copy to clipboard operation
OpenCL-Wrapper copied to clipboard

.end() + 1

Open GhostCore07 opened this issue 2 years ago • 1 comments

https://github.com/ProjectPhysX/OpenCL-Wrapper/blob/deb0a35de21ba8dbfc23a4af7ad9eed1dc6a9542/src/utilities.hpp#L565

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.

GhostCore07 avatar Jul 16 '23 21:07 GhostCore07

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).

maronsson avatar Dec 28 '23 11:12 maronsson