samedi 24 février 2018

Why this c++ broken program behaves so differently in windows and on linux?

mingw gcc 7.3/windows 10; gcc 6.3 debian 9

The following program, if X is set to 1, it will run fine on debian. If X is set to two it will abort right away on debian. But on windows can be 900 and it will without abort with varying output...

int main() {

    vector<int> asdf (5);
    unsigned int X = 2;

    for (unsigned int i = 0; i < asdf.size() + X; i++) {
        asdf[i] = i;
        cout << asdf[i] << "; ";
    }
    cout << '\n';

    return 0;
}

Aucun commentaire:

Enregistrer un commentaire