Menu

#821 LEN() and SIZEOF() should not be allowed when used with bitfields

open
nobody
None
compiler
2016-03-19
2016-03-19
No

The Sizeof() and Len() operators applied to a bitfield always return the size (in bytes) of an Integer (4 / 8 for fbc 32-bit / 64-bit).

That induces incoherence:

Type UDT
  Dim As Ushort a : 1
  Dim As Ubyte  b : 1
End Type

Dim As UDT u
Print Sizeof(UDT)
Print Len(u)
Print Sizeof(u.a)
Print Len(u.b)

Sleep

Output (compiled for 32-bit):

 2
 2
 4
 4

IMHO, better shoulds be to disallow the use of bitfields with Len() and Sizeof().
(because one cannot attribute an own size at each bitfield)

Discussion


Log in to post a comment.

MongoDB Logo MongoDB