Skip to content

make @offsetOf runtime-known for types without well defined memory layout #8642

@andrewrk

Description

@andrewrk
test {
    const S = struct {a: i32, b: i32};
    _ = comptime @offsetOf(S, "b"); // error: unable to resolve comptime value
}

This is marked accepted, because at least one of the two things will happen:

  • Trying to observe the memory layout of a non-well-defined-memory-layout will be a compile error
  • Observing the memory layout of a non-well-defined-memory-layout will give a runtime value

Currently this is marked as accepted with the latter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    breakingImplementing this issue could cause existing code to no longer compile or have different behavior.proposalThis issue suggests language modifications. If it also has the "accepted" label then it is planned.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions