[Oberon] NEW on POINTER TO RECORD always results in NIL (RISC Oberon) - bug?

Zdenek oberon at moravcik.info
Tue May 20 10:17:29 CEST 2014


Hi Michael,

no such bug in LinuxAos rev. 5500
outputs  4x OKn

Note: Texts.Writer unknown to compiler, used KernelLog.String instead.

Zdenek


On 05/19/2014 11:05 PM, Michael Schierl wrote:
> [I tried to post this message about a month ago and never received any
> feedback - seems that it never got approved. Now that I'm subscribed to
> the list, I'll try again :)]
>
>
> Hello,
>
>
> When trying to compile this short example in RISC Oberon (using the
> Windows emulator/distribution from projectoberon.com):
>
> -------------------------------------------
> MODULE BugTest;
>   IMPORT Texts, Oberon;
>   TYPE
>     P1 = POINTER TO P1Desc;
>     P1Desc = RECORD a: INTEGER END;
>     P2 = POINTER TO RECORD a: INTEGER END;
>
>
>   PROCEDURE DebugPrint(VAR str : ARRAY OF CHAR);
>   VAR w : Texts.Writer;
>   BEGIN
>     Texts.OpenWriter(w);
>     Texts.WriteString(w,str);
>     Texts.WriteLn(w);
>     Texts.Append(Oberon.Log, w.buf);
>   END DebugPrint;
>
>   PROCEDURE TestAlloc*();
>     VAR
>       v1: P1;
>       v2: P2;
>       v3: POINTER TO P1Desc;
>       v4: POINTER TO RECORD a: INTEGER END;
>   BEGIN
>     NEW(v1);
>     IF v1 # NIL THEN DebugPrint("OK1") ELSE DebugPrint("NIL1") END;
>     NEW(v2);
>     IF v2 # NIL THEN DebugPrint("OK2") ELSE DebugPrint("NIL2") END;
>     NEW(v3);
>     IF v3 # NIL THEN DebugPrint("OK3") ELSE DebugPrint("NIL3") END;
>     NEW(v4);
>     IF v4 # NIL THEN DebugPrint("OK4") ELSE DebugPrint("NIL4") END;
>   END TestAlloc;
> END BugTest.
> -------------------------------------------
>
> It always outputs "OK1 OK2 OK3 NIL4" into the Log (I'd have expected
> that it printed OK4 as well).
>
> Is that a bug in the compiler, or actually intended behavior?
>
> The actual code I'm using is a bit more complex (I'm playing with adding
> paravirtualized clipboard support and some more things to the emulator;
> if I ever get it working fine, I'll release patches of course, unless
> anyone beats me to it  [edit: which I succeeded and a changed version
> that did not require the kludge that made me find this bug was
> successfully merged into Peter De Wachter's emulator]), and it took me
> quite some time to track down that issue...
>
>
> Regards,
>
>
> Michael
>
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon




More information about the Oberon mailing list