> 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
Kylix doesn't increase the refcount. Add the following line before and after the assignment to print the refcount: writeln(plongint(pchar(w)-8)^); _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel