View Issue Details

IDProjectCategoryView StatusLast Update
0027480FPCCompilerpublic2015-02-16 20:12
ReporterMarladu Assigned ToFlorian  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionno change required 
Platformwin32OSwindows 
Product Version3.1.1 
Summary0027480: {$align} and {$packrecords} directives do nothing
Description Compiling the following code with trunk freepascal for win32, the field rec2.b should have an offset of 16 from start of record but has an offset of 4.
Steps To Reproduceprogram Project1;

type
 rec1=record
  l1,l2,l3,l4:longint;
 end;

{$align 16}{$packrecords 16}
type
 rec2=record
  a:longint;
  b:rec1;
 end;

var
 abc:rec2;

begin
 if (longint(@abc.b)-longint(@abc))<>16 then // this should be 16 but is 4
  halt(1);
end.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Activities

Florian

2015-02-16 19:56

administrator   ~0081142

No, the 3.1.1 behaviour is correct. Align 16 means only a maximum alignment of 16, since there is no type involved requiring such an alignment, the highest needed alignment is used.

Marladu

2015-02-16 20:06

reporter   ~0081143

Last edited: 2015-02-16 20:06

View 2 revisions

But the field rec2.b is 16 byte in size, so from my understanding of the docs of $packrecords ("This means that the elements of a record which have size greater than n will be aligned on n byte boundaries.") I expected that field to have an offset of 16 from start of record.

 If that's really intended, then is the only way to guarantee to 16byte alignment for SSE data fields to manually align with padding data like this?

type
 rec_sse=record
  sse1,sse2,sse3,sse4:single;
 end;

type
 rec_something=record
  actual_data:longint;
  padding_data1,padding_data2,padding_data3:longint;
  sse_data:rec_sse;
 end;

Florian

2015-02-16 20:12

administrator   ~0081144

This is not a help/discussion forum. Please discuss such issues on the mailing lists.

Issue History

Date Modified Username Field Change
2015-02-16 19:53 Marladu New Issue
2015-02-16 19:56 Florian Note Added: 0081142
2015-02-16 19:56 Florian Status new => resolved
2015-02-16 19:56 Florian Resolution open => no change required
2015-02-16 19:56 Florian Assigned To => Florian
2015-02-16 20:06 Marladu Note Added: 0081143
2015-02-16 20:06 Marladu Status resolved => feedback
2015-02-16 20:06 Marladu Resolution no change required => reopened
2015-02-16 20:06 Marladu Note Edited: 0081143 View Revisions
2015-02-16 20:12 Florian Note Added: 0081144
2015-02-16 20:12 Florian Status feedback => resolved
2015-02-16 20:12 Florian Resolution reopened => no change required