Kochekov's blog

By Kochekov, history, 4 years ago, In English

Hello CF community,

I encountered interesting compile error(bug?) while I was preparing contest on Hackerrank. When I run this code:

Code

(you can open any problem and paste it on IDE part of problem), I get this type of error log:

Error (stderr)

And interesting part is that when I change "r+1" to "r" in the code, it works without problem. I do not think it stem from lack of Hackerrank's provided "stack memory". Maybe it cause because of their integrated optimizations in low level while compiling code, but I could not figure out myself. I would be happy if you share you experience if you encountered this type of problem before.

Thanks

  • Vote: I like it
  • +55
  • Vote: I do not like it

| Write comment?
»
4 years ago, # |
Rev. 2   Vote: I like it +8 Vote: I do not like it

Do you know anyone from Hackerrank who has potential on trying to fix this issue? If yes, could you please tag them or share contacts of them? Thanks

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

It's not a compile error. It's stack overflow. Apparently GCC fails to optimize tail call when you use r+1 instead of r.