MinGW results in incorrect compilations of program
The problem was with the code, not the compiler. In Ubuntu, variables are initialized to 0, whereas in windows MinGW does not do this. This led to the false conclusion that compiler was at fault.
Yep. Failure to initialize the iterator variable, in a for loop, is a user error ... not a compiler bug. Even if Ubuntu's compiler has (apparently) initialized it suitably, in this case, that's not a feature you should rely on ... ever. References to uninitialized variables always induce undefined behaviour, which is always a programming error.
I guess you resolved this by yourself, so I'm closing the ticket.
The attached program, when compiled with MinGW, creates an application that on execution gives different results than if the program was compiled by GCC on Linux(i.e. Ubuntu)