t_recptr.mod 493 B

123456789101112
  1. MODULE TRecPtr;
  2. // A global record with pointer fields must emit 8-byte slots in its
  3. // data initialiser (matching the layout); a `w 0` would shrink the
  4. // global so the next globals clobber its tail. Exit 42.
  5. TYPE P = POINTER TO R; R = RECORD a : INTEGER; END;
  6. TYPE L = RECORD head, tail : P; n : INTEGER; END;
  7. VAR g : L; a, b, ExitCode : INTEGER;
  8. BEGIN
  9. g.n := 5;
  10. a := 37; b := 0; (* would overwrite g.n if g were undersized *)
  11. ExitCode := g.n + a (* 42 *)
  12. END TRecPtr.