Skip to content

assertion failure emitting debug info for @sizeOf invalid packed struct containing arrayΒ #25646

@nzombom

Description

@nzombom

Zig Version

0.16.0-dev.747+493ad58ff

Steps to Reproduce and Observed Behavior

Minimum example I could get it down to:

const std = @import("std");
const T = packed struct {
	c: [2]u8,
};
pub fn main() void {
	std.debug.print("{}\n", .{ @sizeOf(T) });
}

I know packed structs can't contain arrays but we shouldn't get a segfault.

Expected Behavior

This compile error:

test.zig:3:5: error: packed structs cannot contain fields of type '[2]u8'
 c: [2]u8,
    ^~~~~
test.zig:3:5: note: type has no guaranteed in-memory representation

which appears when trying to initialize an object of type T.

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend-llvmThe LLVM backend outputs an LLVM IR Module.backend-self-hostedbugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions