Skip to content

stage2: @sizeOf packed struct is not working as in stage1 #12565

Closed as not planned
@igor84

Description

@igor84

Zig Version

0.10.0-dev.3664+02070ae26

Steps to Reproduce

const Rgb24 = packed struct {
    r: u8,
    g: u8,
    b: u8,
};

test {
    try std.testing.expectEqual(@as(usize, 3), @sizeOf(Rgb24));
}

Expected Behavior

The above test should pass.

Some time ago I fixed issues with packed struct in stage1 so that @sizeOf(Rgb24) would return 3 and if I have pixels: []Rgb24 I could use reader.readAll(std.mem.sliceAsBytes(pixels)) to load tightly packed Rgb24 data.

Actual Behavior

Now in stage2 @sizeOf(Rgb24) returns 4 and the array also isn't tightly packed but has additional byte of padding for each element which breaks readAll code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions