Skip to content

Close padding hole in Perl_OpDumpContext struct#24176

Open
richardleach wants to merge 1 commit intoPerl:bleadfrom
richardleach:Perl_OpDumpContext-4bytehole
Open

Close padding hole in Perl_OpDumpContext struct#24176
richardleach wants to merge 1 commit intoPerl:bleadfrom
richardleach:Perl_OpDumpContext-4bytehole

Conversation

@richardleach
Copy link
Contributor

The pahole tool, on AMD64, shows that this commit converts:

struct Perl_OpDumpContext {
        I32                        level;                /*     0     4 */

        /* XXX 4 bytes hole, try to pack */

        UV                         bar;                  /*     8     8 */
        PerlIO *                   file;                 /*    16     8 */
        _Bool                      indent_needed;        /*    24     1 */

        /* size: 32, cachelines: 1, members: 4 */
        /* sum members: 21, holes: 1, sum holes: 4 */
        /* padding: 7 */
        /* last cacheline: 32 bytes */
};

to

struct Perl_OpDumpContext {
        PerlIO *                   file;                 /*     0     8 */
        UV                         bar;                  /*     8     8 */
        I32                        level;                /*    16     4 */
        _Bool                      indent_needed;        /*    20     1 */

        /* size: 24, cachelines: 1, members: 4 */
        /* padding: 3 */
        /* last cacheline: 24 bytes */
};

  • This set of changes does not require a perldelta entry.

The pahole tool, on AMD64, shows that this commit converts:
```
struct Perl_OpDumpContext {
        I32                        level;                /*     0     4 */

        /* XXX 4 bytes hole, try to pack */

        UV                         bar;                  /*     8     8 */
        PerlIO *                   file;                 /*    16     8 */
        _Bool                      indent_needed;        /*    24     1 */

        /* size: 32, cachelines: 1, members: 4 */
        /* sum members: 21, holes: 1, sum holes: 4 */
        /* padding: 7 */
        /* last cacheline: 32 bytes */
};
```

to

```
struct Perl_OpDumpContext {
        PerlIO *                   file;                 /*     0     8 */
        UV                         bar;                  /*     8     8 */
        I32                        level;                /*    16     4 */
        _Bool                      indent_needed;        /*    20     1 */

        /* size: 24, cachelines: 1, members: 4 */
        /* padding: 3 */
        /* last cacheline: 24 bytes */
};
```
@leonerd
Copy link
Contributor

leonerd commented Feb 7, 2026

Fails for g++:

dump.c:1875:13: error: designator order for field ‘Perl_OpDumpContext::bar’ does not match declaration order in ‘Perl_OpDumpContext’

It seems in C++, the order of the named initialisers has to match the order of the fields in the definition. Which seems suuuuuper-annoying as surely the entire point of named initialisers is to remove that interdependence.. Grr. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants