Ciao a tutti, qualcuno saprebbe spiegarmi perché compilando il seguente codice
col flag O3, ottengo il seguente output
? 😕
Compilando senza il flag O3 funziona bene, nel senso che giustamente stampa fino al numero 8.
C++:
#include <iostream>
#include <vector>
using namespace std;
struct A
{
bool flag;
vector<unsigned int> v;
};
int main()
{
A m[3][3] = {{{false, {2, 8, 5}}, {true, {}}, {false, {1}}},
{{true, {} }, {false, {2, 8, 5}}, {false, {11, 18}}},
{{true, {} }, {true, {}}, {false, {1, 5, 2, 8, 5}}}};
for(unsigned int i = 0; i < 3 * 3 && ((*m)[i].flag || (*m)[i].v.size()); ++i)
{
cout << i << endl;
}
}
Codice:
0
1
2
3
4
5
6
7
8
9
10
11
Process returned 0 (0x0) execution time : 0.185 s
Press any key to continue.
Compilando senza il flag O3 funziona bene, nel senso che giustamente stampa fino al numero 8.