[fpc-devel]Pchar issue on Win32 with 1.9.2
Skovrup, Morten Juel
ms at mek.dtu.dk
Fri Jan 16 14:40:47 CET 2004
I didn't find the exact place in the documentation, but this is a change
in behaviour right? It worked in earlier versions of FPC and it works in
From: fpc-devel-admin at lists.freepascal.org
[mailto:fpc-devel-admin at lists.freepascal.org] On Behalf Of Michael Van
Sent: 16. januar 2004 14:29
To: fpc-devel at lists.freepascal.org
Subject: Re: [fpc-devel]Pchar issue on Win32 with 1.9.2
On Fri, 16 Jan 2004, Skovrup, Morten Juel wrote:
> I couldn't get in contact with the bug-report system, but the
> following code behaves incorrectly (compiled using -Sd):
No, it is correct.
The result of a PChar() typecast on an expression is not defined outside
the expression. This is correct behaviour - maybe unexpected. You must
explicitly assign the expression result to a string, and typecase that.
This is documented behaviour!
> program TestConsole;
> AStr,BStr : string;
> procedure WriteStr(p1,p2 : PChar);
> AStr := 'Hel';
> BStr := 'Hi';
> //The following outputs 'Hello Hello'
> WriteStr(PChar(AStr+'lo '),PChar(BStr+'Hi'));
> //The following outputs 'Hello Hi Hi'
> WriteStr('Hello',' Hi Hi');
> fpc-devel maillist - fpc-devel at lists.freepascal.org
fpc-devel maillist - fpc-devel at lists.freepascal.org
More information about the fpc-devel