TheAlgorithms / C-Plus-Plus

Collection of various algorithms in mathematics, machine learning, computer science and physics implemented in C++ for educational purposes.
https://thealgorithms.github.io/C-Plus-Plus
MIT License
29.7k stars 7.05k forks source link

[BUG] timsort - std::bad_array_new_length #2687

Closed Jxtopher closed 2 months ago

Jxtopher commented 3 months ago

Description

Hello all,

For sorting/tim_sort.cpp An exception is thrown: std::bad_array_new_length, when you run this piece of code:

void test(int size) {
    std::cout<<"Try for "<<size<<std::endl;
    int *arr = new int[size];
    for (uint i = 0 ; i < size ; i++) {
        arr[i] = size - i;
    }

    printArray(arr, size);
    timSort(arr, size);
    printf("======\n");
    printArray(arr, size);
    delete arr;
}

For example with test(65); the exception is thrown.

github-actions[bot] commented 2 months ago

This issue has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 2 months ago

Please ping one of the maintainers once you add more information and updates here. If this is not the case and you need some help, feel free to ask for help in our Gitter channel or our Discord server. Thank you for your contributions!