Skip to content

Compiler crashes converting aligned array to many-item pointer or slice #21517

@kulkarniniraj

Description

@kulkarniniraj

Zig Version

0.13.0

Steps to Reproduce and Observed Behavior

const print = @import("std").debug.print;

const DirEntry = extern struct {
    name:               [8] u8,
    ext:                [3] u8,    
};

pub fn main() !void {
    var data_buffer: [512]u8 align(2)= undefined;

    const dir_entry_list: []DirEntry = &data_buffer;
    
    print("dir entry: {s}", .{dir_entry_list[0].name});    
}

Build or run

zig build-exe scratchpad.zig

Compiler crashes:

fish: Job 1, 'zig build-exe scratchpad.zig' terminated by signal SIGSEGV (Address boundary error)

Expected Behavior

Program builds or compiler throws some error.

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