tw2285.pp 750 B

123456789101112131415161718192021222324252627282930313233343536
  1. { %fail }
  2. { Source provided for Free Pascal Bug Report 2285 }
  3. { Submitted by "Sergey Kosarevsky" on 2002-12-25 }
  4. { e-mail: [email protected] }
  5. Type CLASS_CONSTRUCTOR=Function(Param:String):Boolean Of Object;
  6. Type tObject=Object
  7. Constructor Init(Param:String);
  8. End;
  9. var
  10. a,b : longint;
  11. Constructor tObject.Init(Param:String);
  12. Begin
  13. End;
  14. Procedure CheckConstructor(C:CLASS_CONSTRUCTOR);
  15. Begin
  16. a:=Longint(Pointer(C));
  17. WriteLn('a: ',a);
  18. End;
  19. Begin
  20. { This should fail, @tobject.init returns a pointer and
  21. is not compatible with a methodpointer }
  22. CheckConstructor(@tObject.Init);
  23. b:=Longint(Pointer(@tObject.Init));
  24. WriteLn('b: ',b);
  25. if a<>b then
  26. begin
  27. writeln('Error!');
  28. halt(1);
  29. end;
  30. End.