rasterize's blog

By rasterize, history, 8 years ago, In English

Hello, I encountered a strange bug while solving POJ 3278 .

here's my AC solution: http://ideone.com/FdyTlU

Strangely if I submit my solution using G++ and remove the 38th line I get a WA verdict.

Now I tried using random other values instead of -1 to see if it mattered and strangely it doesn't. As long as I return something I pass the tests, it doesn't matter what I return, So I don't really see the point of the line if it's essentially just unreachable code.

SIDE NOTE: Submitting the solution using C++ passes the tests which makes the situation even more confusing.

Is there something related to the compilers that's causing this? Or did I somehow invoke undefined behavior?

Full text and comments »

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