You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
emit-C: Option[&T] / Option[Box[T]] / Option[*T] are tagged structs in C, not with-abi §3's nullable pointer; records holding one diverge from TypeLayout #2036
Found by #2022's new emit-C layout asserts (_Static_assert(sizeof/_Alignof/offsetof == TypeLayout's) on every emitted record).
with-abi.md §3: Option[T] whose payload is a single non-null address (&T, *T, an extern fn, a std Box[T]) lowers to that nullable pointer (8 bytes). The C backend emits every Option as {int32_t tag; union {...}} (16 bytes), so:
Option[&i32]: C 16 bytes, model 8.
type Node { v: i32, next: Option[Box[Node]] } (test/emit_c/generic_struct_instances.w): C 24 bytes, model 16.
Inside one C program the representation is self-consistent, so the corpus passes. But every TypeLayout-derived constant (comptime T.size(), offsets, element sizes the compiler computes from the model) disagrees with the C object, and the C program's data is not the ABI the LLVM backend's is.
#2022 asserts every record except those that hold a nullable-pointer Option (CCodegen.record_holds_nullable_option). That exemption is this issue, and it goes away when the C backend represents these Options as the pointer: Some(x) = x, None = NULL, discriminant from the null test, the payload downcast being the value itself.
Fixed on fix-2036 (PR #2044, commit e607ab3). Nullable-pointer Options are the pointer in emitted C, and every emitted record's layout is asserted against TypeLayout with no exemption. Fixture: test/emit_c/option_nullable_pointer.w.
Activity
emit-C: records take TypeLayout's layout and prove it with _Static_as…
ehartford commentedon Oct 3, 2026
Fixed on fix-2036 (PR #2044, commit e607ab3). Nullable-pointer Options are the pointer in emitted C, and every emitted record's layout is asserted against TypeLayout with no exemption. Fixture: test/emit_c/option_nullable_pointer.w.
Over-aligned elements: Vec buffers aligned for their element; emit-C …
emit-C nullable-pointer Options (#2036); over-aligned heap cells and …
ehartford commentedon Oct 3, 2026
Fixed on main (stack #2045: #2037 + #2044; seed-driven battery GREEN on 0577d56, tree identical to main).