[fpc-devel] Free Pascal Bug 4387 ( Daten.Write('BRTF',4); writes only the pointer to the string, not the string itself. )
Benjamin Rosseaux
benjamin at 0ok.de
Wed Sep 28 14:19:45 CEST 2005
Hello,
http://www.freepascal.org/bugs/showrec.php3?ID=4387
why is this not an (compiler codegen compatibility) bug?
Daten('BRTF',4) should work like in Delphi (with {$MODE DLEPHI}), with
the Delphi compiler Daten('BRTF',4) writes 'BRTF' and not the pointer to
the string. Try it yourself!
Delphi translates it to an const char array without a length byte on the
beginning. And FreePascal not, and this is the bug.
My opinion you should fix this "bug" to keep the Delphi Mode still more
compatible with Delphi And set "not an bug" back to "Unfixed" :)
And I've reposted the bug to
http://www.freepascal.org/bugs/showrec.php3?ID=4390
Benjamin Rosseaux
bugs at freepascal.org schrieb:
>The entry concerning the bug you reported (bug 4387) has been modified:
>
>(View this bug at http://www.freepascal.org/bugs/showrec.php3?ID=4387 )
>Bug ID : 4387
>Title : Daten.Write('BRTF',4); writes only the pointer to the string, not the string itself.
>Name : Benjamin Rosseaux
>Email : benjamin at 0ok.de
>Category : Compiler
>Bug type : Error
>FPC version : 2.0.0
>OS : All
>Date added : 2005-09-27
>Status : Not a bug
>Date fixed :
>Fixer : Peter
>Fix version :
>Description:
>The following code does not write the 'BRTF' string correctly, but instead the pointer to the string:
>
>Folgender Code schreibt den 'BRTF' String nicht korrekt, sondern statt 'BRTF' den Zeiger zur Zeichenkette:
>
> # Register %eax,%edx released
>
># [13906] Daten.Write('BRTF',4);
>
> movl $4,%ecx
>
> # Register %eax allocated
>
> movl $_$ENGINETRACK$_L31021,%eax
>
> # Register %ebx allocated
>
> movl -4(%ebp),%ebx
>
> # Register %edx allocated
>
> movl (%ebx),%edx
>
> # Register %esi allocated
>
> movl 92(%edx),%esi
>
> movl %eax,%edx
>
> movl %ebx,%eax
>
> call *%esi
>
>.section .data
>
> .balign 4
>
>.globl _$ENGINETRACK$_L31019
>
>_$ENGINETRACK$_L31019:
>
>.globl _$ENGINETRACK$_L31021
>
>_$ENGINETRACK$_L31021:
>
> .long _$ENGINETRACK$_L31020
>
> .long -1,4
>
>.globl _$ENGINETRACK$_L31020
>
>_$ENGINETRACK$_L31020:
>
> .ascii "BRTF\000"
>
>
>
>-----
>
>
>
>The following code writes the 'BRTF' correct:
>
>Folgender Code schreibt den 'BRTF' String korrekt:
>
> # Register %eax,%edx released
>
># [13905] Daten.Write(Sign,4);
>
> movl $4,%ecx
>
> # Register %eax allocated
>
> movl $TC_ENGINETRACK_TENGINETRACK_$_SPEICHEREBRT$TENGINESTREAM$$BOOLEAN_SIGN,%eax
>
> # Register %ebx allocated
>
> movl -4(%ebp),%ebx
>
> # Register %edx allocated
>
> movl (%ebx),%edx
>
> # Register %esi allocated
>
> movl 92(%edx),%esi
>
> movl %eax,%edx
>
> movl %ebx,%eax
>
> call *%esi
>
>.section .data
>
> .balign 4
>
># [13897] CONST Sign:ARRAY[1..4] OF CHAR='BRTF';
>
>TC_ENGINETRACK_TENGINETRACK_$_SPEICHEREBRT$TENGINESTREAM$$BOOLEAN_SIGN:
>
> .byte 66,82,84,70
>
>
>
>-----
>
>
>
>Write is/Write Ist:
>
>FUNCTION TEngineStream.Write(CONST Buf;Count:INTEGER):INTEGER;
>
>
>
>
>
>Comment :
>The string is an ansistring which is an pointer that points to some memory location where the data is stored. The typed const is directly the address of the data.
>
>
>
>
>Program:
>
>
>
>
>
More information about the fpc-devel
mailing list