Skip to content

x86_64: packed semantics are not robust #22915

@nektro

Description

@nektro
Contributor

Zig Version

0.14.0-dev.3224+5ab511307

Steps to Reproduce and Observed Behavior

const std = @import("std");

test {
    var s = S.init();
    _ = &s;
}

const S = packed struct {
    a: u48,
    b: u80,

    pub fn init() S {
        var a: u48 = 0;
        var b: u80 = 0;
        _ = .{ &a, &b };
        return S{
            .a = a,
            .b = b,
        };
    }
};
$ zig-master test ./test.zig -fno-llvm -fno-lld
test.zig:12:9: error: TODO airAggregateInit implement packed structs with large fields
    pub fn init() S {
    ~~~~^~~~~~~~~~~

Expected Behavior

all tests passed

Activity

added
bugObserved behavior contradicts documented or intended behavior
on Feb 16, 2025
added this to the 0.14.0 milestone on Feb 21, 2025
modified the milestones: 0.14.0, 0.14.1, 0.15.0 on Mar 1, 2025
changed the title [-]x86_64: TODO airAggregateInit implement packed structs with large fields[/-] [+]x86_64: packed semantics are not robust[/+] on Jun 1, 2025
jacobly0

jacobly0 commented on Jun 1, 2025

@jacobly0
Member

Instruction selection of bitcast, load, store, store_safe, struct_field_val, and aggregate_init on packed pointers/fields need to be rewritten in the self-hosted x86_64 backend.

added
enhancementSolving this issue will likely involve adding new logic or components to the codebase.
and removed
bugObserved behavior contradicts documented or intended behavior
on Jun 1, 2025
added a commit that references this issue on Jun 3, 2025
aedf976
added a commit that references this issue on Jun 3, 2025
80170d0
modified the milestones: urgent, 0.15.0 on Jul 26, 2025
added a commit that references this issue on Aug 4, 2025
8a472d2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-x86_6464-bit x86backend-self-hostedenhancementSolving this issue will likely involve adding new logic or components to the codebase.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      Participants

      @alexrp@nektro@mlugg@jacobly0

      Issue actions

        x86_64: packed semantics are not robust · Issue #22915 · ziglang/zig