Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment to arary member in packed struct will not happen #11514

Closed
iacore opened this issue Apr 24, 2022 · 2 comments
Closed

Assignment to arary member in packed struct will not happen #11514

iacore opened this issue Apr 24, 2022 · 2 comments
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@iacore
Copy link
Contributor

iacore commented Apr 24, 2022

Zig Version

0.10.0-dev.1919+5da0e0355

Steps to Reproduce

Array assignment sometimes doesn't happen.

const std = @import("std");

const Memory = packed struct {
    mouse: u48, // try changing this to u32
    framebuffer: [4]u8,
};

var m: Memory = undefined;
pub fn main() void {
    m.framebuffer[0] = 13;
    std.debug.print("{}", .{m});
}

Expected Behavior

Memory{ .mouse = 13, .framebuffer = { 13, 0, 0, 0 } }

Actual Behavior

Memory{ .mouse = 13, .framebuffer = { 0, 0, 0, 0 } }
@iacore iacore added the bug Observed behavior contradicts documented or intended behavior label Apr 24, 2022
@iacore
Copy link
Contributor Author

iacore commented Apr 24, 2022

Related: #10185

@Vexu Vexu added the stage1 The process of building from source via WebAssembly and the C backend. label Apr 28, 2022
@Vexu Vexu added this to the 0.12.0 milestone Apr 28, 2022
@Vexu
Copy link
Member

Vexu commented Dec 31, 2022

Arrays are no longer allowed in packed structs.

@Vexu Vexu closed this as completed Dec 31, 2022
@andrewrk andrewrk modified the milestones: 0.12.0, 0.11.0 Jan 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Projects
None yet
Development

No branches or pull requests

3 participants