How to detect Runtime Errors in PASCAL
Posted: Fri Oct 06, 2006 1:20 pm
I had several very unpleasant experiences with Runtime Errors (RE) being reported as Wrong Answer (WA).
Reason for those is mentioned in post about 'submitting Pascal'. It turns out that FPC does not emit error signal (at least not under Linux), so if RE occurs your program either just abort, leaving your result output unfinished (and thus producing WA), or it write few error strings and then abort, which again result in WA since those error strings were not expected in output.
But fact that we know WHY it happens does not change fact that it is very annoying when it happens - getting WA instead of RE can result in significant waste of time before you realise that it was RE. Especially for those of us who program and test on different compiler than one run by judge. For example, I use Delphi, and when i suspect some compiler-related issue i test on Windows/DOS version of FPC, but neither of those is same as Linux one run by judge.
I made work-around solution to help me in such cases, and it is basically turning RE into Timeout Errors (TE) instead of WA. Since I made it as block of code that I can include in all my solutions, I decided to post it here and potentially help some of pascal users out here
Reason for those is mentioned in post about 'submitting Pascal'. It turns out that FPC does not emit error signal (at least not under Linux), so if RE occurs your program either just abort, leaving your result output unfinished (and thus producing WA), or it write few error strings and then abort, which again result in WA since those error strings were not expected in output.
But fact that we know WHY it happens does not change fact that it is very annoying when it happens - getting WA instead of RE can result in significant waste of time before you realise that it was RE. Especially for those of us who program and test on different compiler than one run by judge. For example, I use Delphi, and when i suspect some compiler-related issue i test on Windows/DOS version of FPC, but neither of those is same as Linux one run by judge.
I made work-around solution to help me in such cases, and it is basically turning RE into Timeout Errors (TE) instead of WA. Since I made it as block of code that I can include in all my solutions, I decided to post it here and potentially help some of pascal users out here