| 1234567891011121314151617181920212223242526272829303132333435363738 |
- MODULE ArrRecFieldOpenArray;
- (* Repro: an array field of an array-of-record element passed as an open
- array actual. The field's descriptor length word is never initialized
- in the static array-of-record data, so the callee reads length 0 and
- traps. V3-built compilers miscompile this; gm2-built ones happen to
- work. Expected: exit 0. Actual (buggy V3): SIGABRT (134).
- Status: UNFIXED in the general codegen path (see
- docs/summary_l3_selfhost_fix.md). Lower's own tables avoid the
- pattern (flat arrays), so self-hosting is unaffected. *)
- TYPE
- ProcEnt = RECORD
- name : ARRAY [0..63] OF CHAR;
- END;
- VAR
- procs : ARRAY [0..3] OF ProcEnt;
- nProcs : CARDINAL;
- ExitCode: INTEGER;
- PROCEDURE CopyN (src: ARRAY OF CHAR; VAR dst: ARRAY OF CHAR);
- VAR i: CARDINAL;
- BEGIN
- i := 0;
- WHILE (i < 63) AND (src[i] # CHR(0)) DO dst[i] := src[i]; INC(i) END;
- dst[i] := CHR(0)
- END CopyN;
- PROCEDURE NoteProc (name: ARRAY OF CHAR);
- BEGIN
- CopyN(name, procs[nProcs].name);
- INC(nProcs)
- END NoteProc;
- BEGIN
- NoteProc("hello");
- IF procs[0].name[0] = "h" THEN ExitCode := 0 ELSE ExitCode := 1 END
- END ArrRecFieldOpenArray.
|