- Code: Select all
`MODULE testalloc;`

IMPORT Main, Out;

TYPE

P = POINTER TO Pdesc;

Pdesc = RECORD i: INTEGER END;

VAR

p: P;

BEGIN

NEW(p);

p.i := 13;

Out.Int(p.i, 0); Out.Ln

END testalloc.

As you'd expect, I get "13" in the terminal. So far, so good. Now I import also 'Storage':

- Code: Select all
`MODULE testalloc;`

IMPORT Main, Out, Storage;

(* ... same as above *)

Now I get no output at all, and no rt-error either. Either I miss something, or things go haywire somehow. I don't know how 'p' is represented internally, but if I assume it's an address, I can check if it's within the heap boundaries:

- Code: Select all
`(* ... as above *)`

BEGIN

NEW(p);

Out.Hex(SYSTEM.VAL(INTEGER, p), 0); Out.Ln;

p.i := 13;

Out.Int(p.i, 0); Out.Ln

END testalloc.

Without 'Storage' imported, I get '20000220H', with 'Storage' I get '20000204H', which both look OK with a heap starting at '20000200H' (assuming 'p' actually represents an address, ofc).