WikiSort
WikiSort copied to clipboard
Getting a crash in the Rotate function
The line that says Rotate(array, Range_length(range) - count, range, cache, cache_size);
calls into memmove(&array[range2.end - Range_length(range1)], &array[range1.start], Range_length(range1) * sizeof(array[0]));
with a range where the end is less than the beginning, so it causes a crash. Any ideas why? I'm building for the iOS architecture, and on there it appears that size_t is unsigned, is it signed for you?
size_t
is always an unsigned integer type, so the problem can't come from there.
Could you provide a full example that fails for you? Like, a way to generate the input with which you managed to make the algorithm crash? Now, I'm not the maintainer of this project, but I fear that my contributions might be the source of your problems...
Every time I create a list of random integers, it happens. If you do the math in the function calling Rotate, you'll see that it's entirely possible to get a range where the end is less than the beginning.
Oh, that's in the C version. Sorry, I only looked at the C++ one.