[Issue 942] New: a delegate defaults to 8 byte alignment when 4 byte is sufficient
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Feb 8 22:13:29 PST 2007
http://d.puremagic.com/issues/show_bug.cgi?id=942
Summary: a delegate defaults to 8 byte alignment when 4 byte is
sufficient
Product: D
Version: 1.005
Platform: All
OS/Version: All
Status: NEW
Keywords: patch
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: guido at grumpy-cat.com
Delegate variables default to 8 byte alignment. Delegates consist of two
pointer elements and should use 4 byte alignment instead.
The TypeDelegate struct does not override "unsigned alignsize()" from Type and
defaults to using "d_uns64 size(Loc loc)" to determine the alignment, which is
PTRSIZE * 2. mtype.c could be updated as follows:
struct TypeDelegate : Type
{
TypeDelegate(Type *t);
Type *syntaxCopy();
Type *semantic(Loc loc, Scope *sc);
d_uns64 size(Loc loc);
+ unsigned alignsize();
void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs);
Expression *defaultInit();
int isZeroInit();
int checkBoolean();
TypeInfoDeclaration *getTypeInfoDeclaration();
Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
int hasPointers();
type *toCtype();
};
d_uns64 TypeDelegate::size(Loc loc)
{
return PTRSIZE * 2;
}
+unsigned TypeDelegate::alignsize()
+{
+ // A Delegate consists of two ptr-sized values, so align it on pointer
size
+ // boundary
+ return PTRSIZE;
+}
--
More information about the Digitalmars-d-bugs
mailing list