The enlarged stack does not work

How can I correctly increase the stack available for a program using Bloodshed Dev C ++ or Code :: Block? I run a simple bubble sort and quick, but it works, but when I changed the stack in Code :: Block (learned as above here ), it made my program crash even faster, despite the use of a much larger than expected, location. Initially, the program crashes when sorting 64K random integers (using a function rand()). Now its crashing at 32K. im getting the error:Process returned -1073741571 (0xC00000FD)

the program really works faster without changing the stack, assuming I'm doing it right. gcc -Wl,--stack,1099511627776

I can't figure out how to change it at all in Dev C ++

What should I do? is there any way to change the stack inside the code itself? here is im code using for bubble and quicksort. There are two of them: one with vectors, the other with arrays. I think bubble grade. must be correct. quick variety, I'm not so sure. sorry if its a little dirty

vector <int> v_bubble(vector <int> array){
    // Vector Bubble Sort
    if (array.size() < 2){
        return array;
    }
    int s = 1;
    while (s){
        s = 0;
        for (unsigned int x = 0; x < (array.size() - 1); x++){
            if (array[x] > array[x + 1]){
                int t = array[x];
                array[x] = array[x + 1];
                array[x + 1] = t;
                s = 1;
            }
        }
    }
    return array;
}

void a_bubble(int array[], int size){
    // Array Bubble Sort
    int s = 1;
    while (s){
        s = 0;
        for (int x = 0; x < (size - 1); x++){
            if (array[x] > array[x + 1]){
                int t = array[x];
                array[x] = array[x + 1];
                array[x + 1] = t;
                s = 1;
            }
        }
    }
}

vector <int> v_quick(vector <int> array){
    //Vector Quick Sort
    if (array.size() < 2){
        return array;
    }
    vector <int> left;
    vector <int> right;
    int p_location = array.size() / 2 - 1;
    int pivot = array[p_location];
    for(unsigned int x = p_location; x < array.size() - 1; x++){
        array[x] = array[x + 1];
    }
    array.pop_back();
    for(unsigned int x = 0; x < array.size(); x++){
        if (array[x] <= pivot) {
            left.push_back(array[x]);
        }
        else if (array[x] > pivot){
            right.push_back(array[x]);
        }
    }
    vector <int> p;
    p.push_back(pivot);
    return combine(combine(v_quick(left), p), v_quick(right));
}

int a_quick(int array[], int size, int l_index = -1, int r_index = -1){
    //Array Quick Sort
    if (size < 2){
        return array[size];
    }
    array[size] = array[size];
    int left[size];
    int right[size];
    l_index = 0;
    r_index = 0;
    int p_location = size / 2 - 1;
    int pivot = array[p_location];
    for(int x = p_location; x < size - 1; x++){
        array[x] = array[x + 1];
    }
    size--;
    for(unsigned int x = 0; x < size; x++){
        if (array[x] <= pivot) {
            left[l_index] = array[x];
            l_index++;
        }
        else if (array[x] > pivot){
            right[r_index] = array[x];
            r_index++;
        }
    }
    return a_quick(left, l_index, l_index, r_index) + pivot + a_quick(right, r_index, l_index, r_index);
}

the rest of the code simply generates arrays and vectors with 32, 64 and 128 k elements, sorting them using the above code and returning the time. that part im pretty sure i didn't mess up

my main basically just

    start = clock();
    a_quick(array1, 32000);
    end = clock();
    cout << "\nQuick Sort\tArray\t32000\t" << ((double) end - start)/CLOCKS_PER_SEC << " seconds\n";

again and again

+3
source share
2 answers

, , , . , ( GB) .

?

+6

int a_bubble(int array[], int size): array[size], . a_quick().

main().

EDIT: , . , - UB, .

, ? , " ", , .

EDIT2: . int array[1 << 20]? , return array[size]. , void, , .

+1

Source: https://habr.com/ru/post/1777579/


All Articles