View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0037822 | FPC | Compiler | public | 2020-09-27 00:02 | 2021-01-01 15:00 |
Reporter | ravi dion | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | new | Resolution | open | ||
Product Version | 3.3.1 | ||||
Summary | 0037822: Alignment Attribute | ||||
Description | Since FPC supports attributes it'd be nice to control alignment through it | ||||
Steps To Reproduce | {$A4} type TMyRecordA = record x: Integer; y: Int64; end; TMyRecordB = record x: Integer; [Align(8)] y: Int64; end; var a: TMyRecordA; b: TMyRecordB; offset: Integer; begin offset := PByte(@a.y) - PByte(@a); Writeln(SizeOf(a)); Writeln(offset); offset := PByte(@b.y) - PByte(@b); Writeln(SizeOf(b)); Writeln(offset); | ||||
Additional Information | https://wiert.me/2020/09/25/delphi-the-use-of-alignattribute-indicate-the-alignment-of-a-field/ | ||||
Tags | No tags attached. | ||||
Fixed in Revision | |||||
FPCOldBugId | |||||
FPCTarget | - | ||||
Attached Files |
|
|
FPC currently only supports custom attributes for types and published properties, for anything more support for extended RTTI is required first. |
|
What is the use case of this? IMO it makes no sense: if y shall be 8 byte aligned, TMyRecordB must be as well, so just setting the aligment to 8 before the TMyRecordB declaration is enough? |
|
Probably to avoid the need to add either manual paddings when using packed or to have a more granular control. E.g. for reading from a binary file it's not necessary that the record itself is correctly aligned, only that the fields are. |
|
Oh didn't know that extended RTTI is needed. Any ETA for this feature? |
|
> Probably to avoid the need to add either manual paddings when using packed or to have a more granular control. E.g. for reading from a binary file it's not necessary that the record itself is correctly aligned, only that the fields are. I think this is not a good enough reason for this ugly construct :) It would be probably more confusing. If binary reading is required, packed records with dummy fields are imo the way to go. |
|
If you like it or not, it's needed for Delphi compatibility. ;-) |
|
We do not support each Delphi construct anymore, see e.g. inline variable declarations. |
|
Should be realted to 0028927 no? |
Date Modified | Username | Field | Change |
---|---|---|---|
2020-09-27 00:02 | ravi dion | New Issue | |
2020-09-27 11:49 | Sven Barth | Note Added: 0125896 | |
2020-09-27 11:49 | Sven Barth | Note Edited: 0125896 | View Revisions |
2020-10-03 10:30 | Florian | Note Added: 0126051 | |
2020-10-03 10:30 | Florian | Status | new => feedback |
2020-10-03 10:30 | Florian | FPCTarget | => - |
2020-10-03 11:28 | Sven Barth | Note Added: 0126054 | |
2020-10-03 21:22 | ravi dion | Note Added: 0126068 | |
2020-10-03 21:22 | ravi dion | Status | feedback => new |
2020-10-04 19:21 | Florian | Assigned To | => Florian |
2020-10-04 19:21 | Florian | Status | new => resolved |
2020-10-04 19:21 | Florian | Resolution | open => won't fix |
2020-10-04 19:21 | Florian | Note Added: 0126087 | |
2020-10-13 12:46 | ravi dion | Status | resolved => feedback |
2020-10-13 12:46 | ravi dion | Resolution | won't fix => open |
2020-10-13 12:46 | ravi dion | Note Added: 0126281 | |
2020-10-13 20:03 | Florian | Note Added: 0126285 | |
2020-10-13 21:50 | Florian | Assigned To | Florian => |
2021-01-01 13:11 | ravi dion | Note Added: 0127985 | |
2021-01-01 13:11 | ravi dion | Status | feedback => new |
2021-01-01 15:00 | Florian | Relationship added | related to 0028927 |