{$mode delphi}
uses Classes;
type
TUntypedStringTest = class
private
FValue: string;
public
procedure SetValue(const aValue);
procedure PrintValue();
end;
procedure TUntypedStringTest.SetValue(const aValue);
begin
// A pchar is a pointer type, so works with untyped const parameters
// and is assignment compatible with string.
FValue := pchar(@aValue);
end;
procedure TUntypedStringTest.PrintValue();
begin
writeln(FValue);
end;
var
a: TUntypedStringTest;
begin
a := TUntypedStringTest.Create();
a.SetValue('hello'); // no more crash here
a.PrintValue();
readln();
a.Free();
end.