Incorrect results returned from function
Original Reporter info from Mantis: g00r00
-
Reporter name:
Original Reporter info from Mantis: g00r00
- Reporter name:
Description:
I believe I have found a problem with evaluating some function results. Please see the following code in "Steps to Reproduce".
Steps to reproduce:
To reproduce, execute the code below. The resulting value should always be "AB" but it is returning as "BA" unless I call the functions separately.
Program TestCode;
// FPC 2.4.4 Windows 7 64-bit
Var
Count : Byte = 1;
Function GetChar : Char;
Begin
If Count = 1 Then Begin
GetChar := 'A';
Inc(Count);
End Else
If Count = 2 Then GetChar := 'B';
End;
Var
Code : String[2];
Begin
Count := 1;
Code := GetChar + GetChar;
WriteLn ('The following code should have the value of AB');
WriteLn ('Code is: ' + Code);
Count := 1;
Code := GetChar;
Code := Code + GetChar;
WriteLn ('Now the code is: ' + Code);
End.
Mantis conversion info:
- Mantis ID: 20208
- OS: Windows
- OS Build: 7 64-bit
- Build: 2011/04/23
- Platform: Windows
- Version: 2.4.4