Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Compiler/Delphi/BASM    [ Add a report in this area ]  
Report #:  87994   Status: Open
SizeOf evaluated incorrectly in assembly expressions
Project:  Delphi Build #:  15.0.3890.34076
Version:    15.0 Submitted By:   Philipp S
Report Type:  Basic functionality failure Date Reported:  9/12/2010 10:57:40 AM
Severity:    Infrequently encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   280439
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
4.00 out of 5
Total Votes: 15
Description
The use of SizeOf(Type) is seemingly valid in BASM. However, SizeOf(Type) does not  appear to be evaluated correctly in BASM.

Note: this seems to be the case for at least Delphi XE, D2010, D2009 and D2006.
Steps to Reproduce:
Inspect the code generated for the following routine:
Expected: all three statements produce the same code
Observed: those statements containing SizeOf(..) do not produce correct code

procedure Bug_Asm_SizeOf;
type
  TByteSet = set of byte;
const
  SzByteSet = SizeOf (TByteSet); // = 256/8 = 32 bytes = $20 bytes
asm
  mov eax, longword(SizeOf(TByteSet))  //<<< WRONG
  // B831000000       mov eax,$00000031
  mov eax, dword ptr SizeOf(TByteSet)  //<<< WRONG
  // B831000000       mov eax,$00000031
  mov eax, SzByteSet                   //<<< correct
  // B820000000       mov eax,$00000020
end;
Workarounds
None
Attachment
None
Comments

None

Server Response from: ETNACODE01