tw0976.pp 718 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. { Source provided for Free Pascal Bug Report 976 }
  2. { Submitted by }
  3. { e-mail: }
  4. Program Test_Me;
  5. type PDouble = ^Double;
  6. var A, B: PDouble;
  7. x: Double;
  8. Operator + (x: Double; A: PDouble) B: Double;
  9. begin
  10. B := x + A^;
  11. end;
  12. { This was wrong because B value is not initialized !!
  13. Operator + (x: Single; A: PDouble) B: PDouble;
  14. begin
  15. B^ := x + A^;
  16. end; }
  17. begin
  18. new (A);
  19. new (B);
  20. x := 0.5;
  21. A^ := x;
  22. {--- Addition "Double + Double": OK}
  23. B^ := x + A^;
  24. writeln (B^:4:2);
  25. if B^<>1.0 then
  26. Halt(1);
  27. {---Identical error messages for addition "PDouble + Double" and "Double + PDouble"}
  28. {---in spite of overloaded + operator}
  29. // B := A + x;
  30. B^ := x + A;
  31. writeln (B^:4:2);
  32. if B^<>1.0 then
  33. Halt(1);
  34. end.