www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - real.alignof

reply "Thomas Kuehne" <eisvogel users.sourceforge.net> writes:
The alignment size of the type "real" is smaller than it's size.

real.sizeof: 10
real.alignof: 2

Maybe I don't get the point of ".alignof".
Shouldn't it be at least ".sizeof"?

system: Linux / i686

Thomas
Aug 23 2004
parent Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
Thomas Kuehne wrote:
 The alignment size of the type "real" is smaller than it's size.
 
 real.sizeof: 10
 real.alignof: 2
 
 Maybe I don't get the point of ".alignof".
 Shouldn't it be at least ".sizeof"?

Thinking about 32bit machines for a moment...real requires 3 reads or writes, so long as it is aligned to a 2 byte boundary. Aligning it to a 4 byte boundary (or even more) doesn't gain you anything. You just don't want to hit an odd address, since then you might require 4 accesses. On the other hand, you might be bad performance if a real crosses a cache line boundary...perhaps that is an argument for real.alignof=16 ?
Aug 23 2004