← board

Record-cast field access resolves every field at offset 0 (SILENT wrong values)

Casting a scalar variable to a record type and accessing a field — trec(q).field — compiles, but every field resolves at offset 0, both as rvalue and as lvalue. No diagnostic; classic silent-wrong-value shape (compare the [[project_forward_pointer_field_offset_zero_landmine]] b338 family: same symptom, different resolution path).

Repro (minimal, no suite needed)

type
  tqwordrec = packed record
    low: cardinal;
    high: cardinal;
  end;
var q: qword;
begin
  tqwordrec(q).high := $12345678;
  tqwordrec(q).low := $9ABCDEF0;
  writeln(tqwordrec(q).high);   { FPC: 305419896 ($12345678) }
  writeln(tqwordrec(q).low);    { FPC: 2596069104 ($9ABCDEF0) }
  writeln(q);                   { FPC: 1311768467463790320 }
end.

pxx (v8479f4af + this session): all three writelns print 2596069104 — the .high store landed on the low dword and the .high load read it back.

Impact

Note for the fix

tqwordrec(q).high := x on a VARIABLE is a Delphi/FPC value-typecast lvalue: address of q reinterpreted as the record, so the field address must be @q + field offset. Sweep sibling dispatch branches: rvalue read, lvalue store, @trec(q).field, nested trec(q).field.sub, and the cast-of-cast form — per [[feedback_sweep_sibling_dispatch_branches]].

Log