View Issue Details

IDProjectCategoryView StatusLast Update
0020335FPCCompilerpublic2018-02-04 19:39
ReporterAlex_LutovininAssigned ToJonas Maebe 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionwon't fix 
Platformx86, armOSLinuxOS Version
Product Version2.4.2Product Build 
Target VersionFixed in Version 
Summary0020335: result of a cast expression (compatible with Delphi)
DescriptionExample of different calculation result in FPC and Delphi.

var P: Word;
    H,L: Byte;
begin
 P:= $FFFF;
 L:= Lo(P div 64);
 H:= Hi(P div 64);
 Writeln('Lo=', L, ' Hi=', H);
 //
 L:= Lo(Word(P div 64));
 H:= Hi(Word(Page div 64));
 Writeln('Lo=', L, ' Hi=', H);
end.

Result:

Lo=1023 Hi=0 <- result of the Delphi: Lo=255 Hi=3
Lo=255 Hi=3
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Relationships

has duplicate 0033128 resolvedMichael Van Canneyt Compiler does not respect evaluation order with HI/LO 

Activities

Jonas Maebe

2011-09-23 15:11

manager   ~0052129

That is by design and has been like that in FPC since the beginning. If you compile in TP or Delphi mode, you will also get a warning about this:

tt6.pp(5,5) Warning: lo/hi(dword/qword) returns the upper/lower word/dword
tt6.pp(6,5) Warning: lo/hi(dword/qword) returns the upper/lower word/dword

It's also documented at http://www.freepascal.org/port.var

Issue History

Date Modified Username Field Change
2011-09-23 14:57 Alex_Lutovinin New Issue
2011-09-23 15:11 Jonas Maebe Status new => resolved
2011-09-23 15:11 Jonas Maebe Resolution open => won't fix
2011-09-23 15:11 Jonas Maebe Assigned To => Jonas Maebe
2011-09-23 15:11 Jonas Maebe Note Added: 0052129
2018-02-04 19:39 Florian Relationship added has duplicate 0033128