Hi all, the bug-report on the website doesn't work, so I write a mail:
If you assign a widechar to a pwidechar, the refcount isn't increased. This construct is often used in the variants-code, which is allowed, according to the comments at the top of wstrings.inc. An example: Program test; var PW : PWideChar; dummy : AnsiString; procedure Set_PW; var W : WideString; s : ansistring; begin s := 'Hello world'; // Can't assign directly to W, because that's W := s; // interpreted as a constant with a refcount of -1 PW := PWideChar(W); // <- Bug, refcount of W (and PW) isn't increased end; // <- Memory at @W is deallocated, since refcount=0 begin Set_PW; SetLength(Dummy,3); // The dummy is allocated at the same address as PW writeln(pchar(PW)[0]); // Should write 'H', but it doesn't end. JoJo, Joost. _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel