Skip to content

@[align(N)] struct: reading the padded field prints <unsupported> #1445

Closed

Description

@ehartford

Summary

Reading an @[align(N)] struct field whose alignment inserts padding prints <unsupported> (and a later field of enum type printed <invalid enum> in a larger repro): the field read resolves the padding member's type, not the field's.

Repro (origin/main 1c76062)

type A {
    a: i8,
    @[align(16)]
    b: i64,
    c: i64,
}

fn main:
    let v = A { a: 5, b: 1111111111111, c: 2222222222222 }
    let b = v.b
    print(f"a={v.a} b={b} c={v.c} size={size_of[A]()}")

Prints a=5 b=<unsupported> c=2222222222222 size=32; expected b=1111111111111. The size is right (the padded body { i8, [15 x i8], i64, i64 }); declare_struct_type records the LLVM field index in struct_llvm_field_indices, so some read path is indexing the LLVM body by the source field index (or taking the type of LLVM element 1, the padding array).

Activity

  1. ehartford commented on Sep 26, 2026

    @ehartford
    ContributorAuthor

    Verified fixed on main 55739d4 (release binary): @[align] padded field prints a=5 b=… size=32.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions