Strange Bug.

Revision en3, by rasterize, 2016-12-16 23:10:55

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?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English rasterize 2016-12-16 23:10:55 4
en2 English rasterize 2016-12-16 23:10:16 398
en1 English rasterize 2016-02-14 19:07:49 466 Initial revision (published)