RFR: 7903481: Jextract doesn't enforce group layout alignment correctly in some cases

Jorn Vernee jvernee at openjdk.org
Tue May 30 12:04:17 UTC 2023


On Tue, 30 May 2023 11:49:05 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> This patch overhauls the treatment of pragma packs directives.
> 
> The current logic tries to detect fields occurring at misaligned offsets, and relaxes alignment constraints for these fields.
> However, in cases like this:
> 
> 
> #pragma pack(push, 1)
> struct A {
>    long long a;
>    int b;
> }
> 
> 
> Each field is correctly aligned. But the struct size (12) is not a multiple of its natural alignment (8). As a result, we run into issues when building a sequence layout out of this struct, because of the eager checks added to the layout API.
> 
> This patch fixes support for packed structs "the right way", that is, by asking clang the struct/union alignment, and then making sure that any field is aligned accordingly before the group layout is created.

Marked as reviewed by jvernee (Committer).

-------------

PR Review: https://git.openjdk.org/jextract/pull/121#pullrequestreview-1450774885


More information about the jextract-dev mailing list