Блог пользователя I_love_Hoang_Yen

Автор I_love_Hoang_Yen, история, 9 лет назад, По-английски

So if you have been coding C++ for a long time, you see people discover bugs in g++ every now and then, for example: this, that, here and there.

In this comment regarding IOI, andreyv said "On IOI they will most likely use the Linux distribution's default GCC, which was tested to build the numerous distribution's packages" and we should not worry about it.

But g++ is also widely used in ACM regionals, which is setup by some hosting university.

So, I have few questions:

  1. Is there any way that we can avoid compiler issues when writing code? e.g. Avoid some specific/strange coding pattern? Pray to god?
  2. How likely do you think that this can actually happen in a contest and affect someone?
  3. Do you know / have been involved in preparing ACM contests & know if people carefully select compiler version?
  • Проголосовать: нравится
  • +28
  • Проголосовать: не нравится

»
9 лет назад, # |
Rev. 3   Проголосовать: нравится +76 Проголосовать: не нравится

The fourth thread you linked to wasn't a compiler bug.

  1. No.
  2. The probability is negligible. Looking at the number of submissions and the number of bugs detected, the odds are most likely smaller than one in a million.
  3. No, not really. Usually the organizers either reuse a setup they have already used and tested previously, or they simply take the most recent stable version from their distro. Both are good enough in that they make the chance of random competition-affecting bugs a bit lower.

Honestly, there are enough other, more important things to worry about when preparing for a contest. Just ignore this one and pretend that it doesn't happen. You'll be fine.

  • »
    »
    9 лет назад, # ^ |
      Проголосовать: нравится -12 Проголосовать: не нравится

    About 1. One option is not to use -O2 on online judges, but use -O1 or -O0. Also it reduces gap between performance of C++ and Java.

»
9 лет назад, # |
  Проголосовать: нравится +11 Проголосовать: не нравится

Here's one thing you should hope doesn't happen and has better chances of happening than hitting a compiler bug: your computer shuts down in the middle of the contest (possible bonus: all unsubmitted code, lost forever). I think something similar happened to someone during last CERC.