Q:

Is there something wrong with the index number of array in merge sort?

So I am trying to implement merge sort in C++, and this version uses O(n) of space complexity.
This algorithm is written using pseudo-code found in the book "Foundation of Algorithms".
I think there are some errors when using the index in the function merge2.
The variables that end with _tmp are used to manipulate the array U, and variables without _tmp are used to manipulate the array S.
#include <iostream>

int n = 8;
int S[8] = { 0, };

void mergeSort2(int low, int high);
void merge2(int low, int mid, int high);

void mergeSort2(int low, int high) {
    int mid;
    if (low < high) {
        mid = (low + high) / 2;
        mergeSort2(low, mid);
        mergeSort2(mid + 1, high);
        merge2(low, mid, high);
    }
}

void merge2(int low, int mid, int high) {
    int i, j, k;
    int i_tmp, j_tmp, k_tmp;
    int high_tmp = high - low;
    int low_tmp = 0;
    int mid_tmp = high / 2;
    i_tmp = low_tmp; j_tmp = mid_tmp + 1; k_tmp = low_tmp;
    i = low; j = mid + 1; k = low;
    int* U = new int[high_tmp + 1];
    while (i <= mid && j <= high) {
        if (S[i] < S[j]) {
            U[k_tmp] = S[i];
            i++;
            i_tmp++;
        }
        else {
            U[k_tmp] = S[j];
            j++;
            j_tmp++;
        }
        k++;
        k_tmp++;
    }
    if (i_tmp > mid_tmp) {
        //move S[j] through S[high] to U[k] through U[high-1]
        for (int r = j, s = k_tmp; r < high, s < high_tmp; r++, s++) {
            U[s] = S[r];
        }
    }
        else {
        //move S[i] through S[mid] to U[k] through U[high-1]
        for (int r = i, s = k_tmp; r < mid, s < high_tmp; r++, s++) {
            U[s] = S[r];
        }
    }
    //move U[low] through U[high] to S[low] through S[high-1]
    for (int r = low_tmp, s = low; r < high_tmp, s < high; r++, s++) {
        S[s] = U[r];
    }
    delete U;
}

int main() {
    std::cout << "Enter the elements of the array S (size : " << n << ") : ";
    for (int i = 0; i < n; i++) {
        std::cin >> S[i];
    }
    mergeSort2(0, n);
    std::cout << std::endl;
    std::cout << "Result of array S sorted in an ascending order : ";
    for (int i = 0; i < n; i++) {
        std::cout << S[i] << "  ";
    }
    std::cout << std::endl << std::endl;
    return 0;
}

A:

As pointed out in the comments, the problem is with your for loops' test conditions using the comma operator. As described in cppreference:

In a comma expression E1, E2, the expression E1 is evaluated, its
  result is discarded ... before evaluation of the expression E2 begins ...

So, in the loop:
for (int r = j, s = k_tmp; r < high, s < high_tmp; r++, s++) {
   //...

the r < high expression is never used and the loop will only end when the s < high_tmp expression evaluates to false.
If you want the loop to end when either expression is false, you need to combine the two tests with && (logical AND operator):
for (int r = j, s = k_tmp; r < high && s < high_tmp; r++, s++) {
   //...

