View Issue Details

IDProjectCategoryView StatusLast Update
0028927FPCCompilerpublic2021-01-01 15:00
ReporterFiji Assigned ToFlorian  
PrioritynormalSeverityfeatureReproducibilityalways
Status resolvedResolutionfixed 
PlatformWindowsOS8.1 
Product Version3.1.1 
Fixed in Version3.3.1 
Summary0028927: Alignment syntax
DescriptionThis will not compile for 32 or 64. Has been added in XE2 I think.

program Project1;

{$mode delphi}

type
  TRecord1 = record
  end align 16;

  TRecord2 = record
  end align 8;

  TRecord3 = record
  end align 4;

begin
end.
               
TagsNo tags attached.
Fixed in Revision47892
FPCOldBugId
FPCTarget-
Attached Files

Relationships

related to 0037822 new Alignment Attribute 

Activities

Thaddy de Koning

2015-10-29 12:03

reporter   ~0086985

Last edited: 2015-10-29 12:03

View 2 revisions

Yes, this compiles with XE2.
It does not compile with trunk.

Can you plz add this line in the future instead of just {$mode delphi}?
{$ifdef fpc}{$mode delphi}{$H+}{$endif}

Makes life easier for testers in behavior between Delphi and FPC ;)

Thaddy de Koning

2015-10-29 12:34

reporter   ~0086988

Note the FPC equivalent is {$packrecords X}

Fiji

2015-10-29 12:55

reporter   ~0086989

That packs every record in the unit? align is specific to the local record ;)

Jonas Maebe

2015-10-29 14:34

manager   ~0086991

Does this "align" modifier in fact change the packrecords setting for that record, or does it specify that this record must start on an address that is a multiple of the specified alignment? Those are two completely different things.

Thaddy de Koning

2015-10-29 16:26

reporter   ~0086993

@Fiji: you're wrong again.
{$ifdef fpc}{$mode delphi}{$H+}{$endif}
type
  {$push}
  {$packrecords 16}
  TRecord1 = record
  end {align 16};

  {$packrecords 8}
  TRecord2 = record
  end {align 8};

  {$packrecords 4}
  TRecord3 = record
  end {align 4};
  {$pop}
begin
end.

Thaddy de Koning

2015-10-29 16:28

reporter   ~0086994

Last edited: 2015-10-29 16:51

View 2 revisions

Jonas, this seems to be about field alignment (a multiple of) X and specific to the record that contains the align decorator.

I have to investigate this further. Official docs are hard to find for this one.

Thaddy de Koning

2015-10-29 16:40

reporter   ~0086995

I found:
http://qc.embarcadero.com/wc/qcmain.aspx?d=87283. Interesting and open

The usual http://docwiki.embarcadero.com/RADStudio/Seattle/en/Internal_Data_Formats#Record_Types which is unclear about this syntax

And the most informative, but by no means conclusive:
http://stackoverflow.com/questions/8460862/what-does-packed-now-forces-byte-alignment-of-records-mean

Thaddy de Koning

2015-10-29 16:53

reporter   ~0086996

Last edited: 2015-10-29 16:54

View 2 revisions

@Fiji

If you read the open (acknowledged) bug report in Emb. QC, I guess best advice is not to use that feature with that syntax anyway. It is buggy in Delphi. It would be silly to implement this.

And FPC has a working alternative syntax.

Thaddy de Koning

2015-10-29 17:13

reporter  

AlignPackedBug.dpr (1,691 bytes)

Thaddy de Koning

2015-10-29 17:16

reporter   ~0086998

Last edited: 2015-10-29 17:25

View 3 revisions

I attached an example that is freepascallified from Emb. QC.
It shows alignment working as expected. ($xxxx xxx0)

Note that this may indicate another bug: SizeOf() isn't correct. The alignment IS.

You can play with the example and it always aligns the fields as instructed.
Ignore the SizeOf(). That's something else.

Misha Strong

2015-10-30 07:06

reporter   ~0087004

I am a professional programmer, but I have never needed this function.

Thaddy de Koning

2015-10-31 12:00

reporter   ~0087042

@Misha: I do not understand the value of your comment. Does it contain a hidden solution?

Misha Strong

2015-10-31 18:42

reporter   ~0087044

Thaddy, go back to Langley :)

Issue History

Date Modified Username Field Change
2015-10-28 19:24 Fiji New Issue
2015-10-28 19:26 Jonas Maebe Severity minor => feature
2015-10-29 12:03 Thaddy de Koning Note Added: 0086985
2015-10-29 12:03 Thaddy de Koning Note Edited: 0086985 View Revisions
2015-10-29 12:34 Thaddy de Koning Note Added: 0086988
2015-10-29 12:55 Fiji Note Added: 0086989
2015-10-29 14:34 Jonas Maebe Note Added: 0086991
2015-10-29 16:26 Thaddy de Koning Note Added: 0086993
2015-10-29 16:28 Thaddy de Koning Note Added: 0086994
2015-10-29 16:40 Thaddy de Koning Note Added: 0086995
2015-10-29 16:51 Thaddy de Koning Note Edited: 0086994 View Revisions
2015-10-29 16:53 Thaddy de Koning Note Added: 0086996
2015-10-29 16:54 Thaddy de Koning Note Edited: 0086996 View Revisions
2015-10-29 17:13 Thaddy de Koning File Added: AlignPackedBug.dpr
2015-10-29 17:16 Thaddy de Koning Note Added: 0086998
2015-10-29 17:24 Thaddy de Koning Note Edited: 0086998 View Revisions
2015-10-29 17:25 Thaddy de Koning Note Edited: 0086998 View Revisions
2015-10-30 07:06 Misha Strong Note Added: 0087004
2015-10-31 12:00 Thaddy de Koning Note Added: 0087042
2015-10-31 18:42 Misha Strong Note Added: 0087044
2020-12-29 19:26 Florian Assigned To => Florian
2020-12-29 19:26 Florian Status new => resolved
2020-12-29 19:26 Florian Resolution open => fixed
2020-12-29 19:26 Florian Fixed in Version => 3.3.1
2020-12-29 19:26 Florian Fixed in Revision => 47892
2020-12-29 19:26 Florian FPCTarget => -
2021-01-01 15:00 Florian Relationship added related to 0037822