JonRobertson 72 Posted March 21 A project that I inherited has warning "W1047 Unsafe code" enabled. I normally do not enable that warning. There is a scenario that I don't understand, even after some online searches. [dcc32 Warning] W1047 Unsafe code 'String index to var param' From a couple posts that I read, it seems this specific unsafe warning is related to multiple platform support and zero based strings. It occurs in this (totally useless) code segment: function Test(const aStr: String): String; begin SetLength(Result, Length(aStr)); var Count := 0; for var i := 1 to Length(aStr) do begin Inc(Count); Result[Count] := aStr[i]; end; end; on Result[Count] := aStr; The wording of the warning confuses me. There is an index to a string, but not what I consider a 'string index'. Does the [] operator for String receive the index as a var param? Share this post Link to post
Stefan Glienke 2006 Posted March 21 See https://stackoverflow.com/a/37688891/587106 Share this post Link to post