tw1152.pp 740 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. { Source provided for Free Pascal Bug Report 1152 }
  2. { Submitted by "Dirk Verwiebe" on 2000-09-30 }
  3. { e-mail: [email protected] }
  4. {$mode objfpc}
  5. program exception;
  6. uses sysutils,crt;
  7. var
  8. saveexit : pointer;
  9. finally_called : boolean;
  10. procedure my_exit;
  11. begin
  12. exitproc:=saveexit;
  13. if not finally_called then
  14. begin
  15. Writeln('Problem with exception handling if crt unit is used');
  16. RunError(1);
  17. end
  18. else
  19. begin
  20. Writeln('Exception handling works');
  21. exitcode:=0;
  22. end;
  23. end;
  24. var
  25. p : pointer;
  26. BEGIN
  27. saveexit:=exitproc;
  28. exitproc:=@my_exit;
  29. finally_called:=false;
  30. try
  31. p:=$ffffffff;
  32. longint(p^):=0;
  33. finally
  34. finally_called:=true;
  35. writeln('Error !!!');
  36. end;
  37. END.