1.2.78 $V or $VARSTRINGCHECKS : Var-string checking

The {$VARSTRINGCHECKS } determines how strict the compiler is when checking string type compatibility for strings passed by reference. When in the + or ON state, the compiler checks that strings passed as parameters are of the same string type as the declared parameters of the procedure.

By default, the compiler assumes that all short strings are type compatible. That is, the following code will compile:

Procedure MyProcedure(var Arg: String[10]);  
 
begin  
  Writeln('Arg ',Arg);  
end;  
 
Var  
  S : String[12];  
 
begin  
  S:='123456789012';  
  Myprocedure(S);  
end.

The types of Arg and S are strictly speaking not compatible: The Arg parameter is a string of length 10, and the variable S is a string of length 12: The value will be silently truncated to a string of length 10.

In the {$V+} state, this code will trigger a compiler error:

testv.pp(14,16) Error: string types doesn't match, because of $V+ mode

Note that this is only for strings passed by reference, not for strings passed by value.