How to prevent automate assign of PChar to String
Summary
For now, FPC automatically set a PChar to a String value and I want to disallow it for safety. It is not allowed in {$MODE TP} but there is $MODESWITCH PCHARTOSTRING-} that should work but not
Example Project
program Project1;
var
A: PChar;
B: String;
begin
A := GetMem(3);
A[0] := 'x';
A[1] := 'y';
A[2] := #0;
B := A; //Assign automatically
WriteLn(B);
ReadLn;
end.
Relevant 3rd party information
Forum post: https://forum.lazarus.freepascal.org/index.php/topic,66361.0.html
Here is a patch to fix the issue and activate PCHARTOSTRING back. pchar_2_string.patch