arrrec-field-openarray.mod 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. MODULE ArrRecFieldOpenArray;
  2. (* Repro: an array field of an array-of-record element passed as an open
  3. array actual. The field's descriptor length word is never initialized
  4. in the static array-of-record data, so the callee reads length 0 and
  5. traps. V3-built compilers miscompile this; gm2-built ones happen to
  6. work. Expected: exit 0. Actual (buggy V3): SIGABRT (134).
  7. Status: UNFIXED in the general codegen path (see
  8. docs/summary_l3_selfhost_fix.md). Lower's own tables avoid the
  9. pattern (flat arrays), so self-hosting is unaffected. *)
  10. TYPE
  11. ProcEnt = RECORD
  12. name : ARRAY [0..63] OF CHAR;
  13. END;
  14. VAR
  15. procs : ARRAY [0..3] OF ProcEnt;
  16. nProcs : CARDINAL;
  17. ExitCode: INTEGER;
  18. PROCEDURE CopyN (src: ARRAY OF CHAR; VAR dst: ARRAY OF CHAR);
  19. VAR i: CARDINAL;
  20. BEGIN
  21. i := 0;
  22. WHILE (i < 63) AND (src[i] # CHR(0)) DO dst[i] := src[i]; INC(i) END;
  23. dst[i] := CHR(0)
  24. END CopyN;
  25. PROCEDURE NoteProc (name: ARRAY OF CHAR);
  26. BEGIN
  27. CopyN(name, procs[nProcs].name);
  28. INC(nProcs)
  29. END NoteProc;
  30. BEGIN
  31. NoteProc("hello");
  32. IF procs[0].name[0] = "h" THEN ExitCode := 0 ELSE ExitCode := 1 END
  33. END ArrRecFieldOpenArray.