Skip to content

Incorrect alignment type for members and slices of aligned array #11751

@markisus

Description

@markisus

Zig Version

0.9.1

Steps to Reproduce

Just because an array is aligned, it does not imply that each member of the array is aligned, nor does it imply that arbitrary slices of it are aligned.

test "alignment test" {
    var buf: [1024]u8 align(64) = undefined;
    var start: usize = 1;
    var end: usize = undefined;
    std.debug.print("\n", .{});
    std.debug.print("buf[start..end] => {s}\n", .{@TypeOf(buf[start..end])});
    std.debug.print("&buf[start..end][0] => {s}\n", .{@TypeOf(&(buf[start..end][0]))});
    std.debug.print("&buf[start] => {s}\n", .{@TypeOf(&(buf[start]))});
}

Expected Behavior

buf[start..end] => []u8
&buf[start..end][0] => *u8
&buf[start] => *u8

Actual Behavior

buf[start..end] => []align(64) u8
&buf[start..end][0] => *align(64) u8
&buf[start] => *u8

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorstage1The process of building from source via WebAssembly and the C backend.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions