Vakhtang Tabatadze
Vakhtang Tabatadze

Reputation: 1

Differences between GNU C++ 4.8.1 (MinGW) and Visual C++ 2013

I know question like this have been asked before, but there isn't the exact answer I'm searching for.

Today I was writing ACM-ICPC contest with my team. Usually we are using GNU C++ 4.8.1 compilator (which was available on contest). We had written code, which had time limit exceeded on test case 10. At the end of contest, less then 2 minutes remaining, I sent the exactly same submission with Visual C++ 2013 (same source file, different language) it got accepted and worked. There were more than 60 test cases and our code passed them all. Once more I say that there were no differences between the source codes. Now I'm just interested why it happened.

Anyone knows what the reason is?

Upvotes: 0

Views: 778

Answers (1)

Twonky
Twonky

Reputation: 796

Without knowing the exact compiler options you used, this answer might be a bit difficult to answer. Usually, compilers come with many options and provide some default values which are used as long as the user does not override them. This is also true for code optimization options. Both mentioned compilers are capable to significantly improve the speed of the generated binary when being told so. A wild guess would be that in our case, the optimization settings used by the GNU compiler did not improve the executable performance so much but the VC++ settings did. For example because not any flags were used in one case. Another wild guess would be that one compiler was generating a debug binary and the other did not (check for the option -g with GCC which switches debug symbol generation on).

On the other hand, depending on the program you created, it could of course be that VC++ was simply better in performing the optimization than g++.

If you are interested in easy increasing the performance, have a look at the high-level optimization flags at https://gcc.gnu.org/onlinedocs/gnat_ugn/Optimization-Levels.html or for the full story, at the complete list at https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html.

More input on comparing compilers:

Upvotes: 1

Related Questions