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

Автор Ebiarat, история, 3 года назад, По-английски

Hi everyone! for now i was using this
#pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") in my template ,howewer i got WA 2 times due to this pragmas.

i have heard that pragmas can cause TLE but i have never heard that this can cause WA. So can any one tell how pragmas really work and why it can cause WA?

  • Проголосовать: нравится
  • -8
  • Проголосовать: не нравится

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

Without any other information or a source code to look at, I can only speculate that it might have been a usual case of a https://en.wikipedia.org/wiki/Heisenbug

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

gcc at -O2 and up will try to remove as much code as possible (fastest code is nonexistent code) and if you happen to be using something that's reliable/predictable but technically undefined behavior, it'll look like sections of your code are just weirdly missing. A TLE can come from a loop being told to terminate after an int rolls over at its max, buuut since that predictable reliable rollover to min is technically undefined, the check that depends on that value will just get nuked and the loop allowed to run indefinitely. Again, given the 'take it out if undefined' behavior from some types of optimizations, it's not hard to imagine something similar resulting in a WA. Or not. Hard to say without any code.