#1 2020-09-09 07:56:11

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,673
Website

Delphi 10.4.1 and record alignment

Some regression has been reported with Delphi 10.4.1 and SynPDF.

From the Github issue description: Generating a PDF via VLCCanvas and TPdfDocumentGDI causes access violation when compiled with Delphi 10.4.1 with record field alignment compiler option set to "byte" or "off". When this option is set to either of "word", "double word" or "quad word", the PDF gets created without errors. The same exact code works fine when compiled with Delphi 10.4 (patch 3), regardless of the field alignment flag.
https://github.com/synopse/SynPDF/issues/40

Sadly, I don't have access to Delphi 10.4.1 since I don't have any commercial licence, and I am waiting for the Community Edition - which is still 10.3 IIRC. So I couldn't debug the root cause and fill a JIRA ticket to EMB. We tried to add a {$A+} at the beginning of the unit, to force the default record alignment. And it seemed to work. So we included the directive for all of our units, in the shared Synopse.inc file, which is included in every of our source code units.
https://github.com/synopse/mORMot/commi … 3e5978c077

This blog entry is mainly to notify about this issue, and be able to share the solution/workaround we found, which be perhaps be investigated more deeply by Delphi users of 10.4.1. I guess that this problem may occur for other projects, when calling raw API.
https://blog.synopse.info/?post/2020/09 … phi-10.4.1

Offline

#2 2020-09-09 11:42:45

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,673
Website

Re: Delphi 10.4.1 and record alignment

Seems to be indeed a compiler bug.

Thanks François and Stefan for the good investigation in https://en.delphipraxis.net/topic/3453- … elphi-1041!

Reported initially as https://quality.embarcadero.com/browse/RSP-30787 and more specifically as https://quality.embarcadero.com/browse/RSP-30890

To be honest, setting an alignment to "byte" for a whole project is a pretty weird idea, and should never be done in practice.
Default alignment is good for performance and compatibility. If you need no alignment for a record or a class, just use {$A-} ...{$A+} locally.

Offline

Board footer

Powered by FluxBB