<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class="">It seems that the Oberon 2013 compiler on RISC creates type descriptors only for *named* record types, but not for *anonymous* record types. This creates a problem if a dynamic variable pointing to an anonymous record type is allocated in the heap via the predefined procedure NEW.</div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class=""><br class=""></div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class="">For example, in the following test program:</div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class=""><br class=""></div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class=""><div class=""> MODULE M;</div><div class=""> TYPE R* = RECORD i: INTEGER END;</div><div class=""><br class=""></div><div class=""> VAR x*: POINTER TO R;</div><div class=""> y*: POINTER TO RECORD x, y, z: INTEGER END;</div><div class=""><br class=""></div><div class=""> PROCEDURE P*;</div><div class=""> BEGIN NEW(x)</div><div class=""> END P;</div><div class=""><br class=""></div><div class=""> PROCEDURE Q*;</div><div class=""> BEGIN NEW(y)</div><div class=""> END Q;</div><div class=""><br class=""></div><div class=""> END M.</div><div class=""><br class=""></div><div class="">the pointer variable 'x' points to a dynamic record of *named* record type 'R' for which a type descriptor is created by the compiler when the declaration for 'R' is processed. However, the pointer variable 'y' points to an *anonymous* record type for which *no* type descriptor is created by the compiler. So the command M.Q will crash the system as soon as the garbage collector uses the type tag of ‘y' to access the (non existing) type descriptor of the anonymous record pointed to by ‘y’.</div><div class=""><br class=""></div><div class="">The proposed solution is to also creates a type descriptor for a variable declaration of a pointer variable pointing to an *anonymous* record type. This is achieved by adding a single line to procedure ORP.Type0:</div></div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class=""><br class=""></div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class=""> PROCEDURE Type0(Var type: ORB.Type);</div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class=""> ...</div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class=""> BEGIN</div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class=""> ...</div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class=""> IF sym = ORS.ident THEN ...</div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class=""> ELSIF sym = ORS.array THEN ....</div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class=""> ELSIF sym = ORS.record THEN ...</div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class=""> ELSIF sym = ORS.pointer THEN ....</div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class=""> ...</div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class=""> IF sym = ORS.ident THEN ...</div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class=""> ELSE Type(type.base);</div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class=""> IF type.base.form # ORB.Record THEN ORS.Mark("must point to record”)</div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class="">--> ELSIF (type.base.typobj = NIL) & (level = 0) THEN ORG.BuildTD(type.base, dc) (*type descriptor; len used as its address*)</div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class=""><div class=""> END ;</div><div class=""> CheckRecLevel(level)</div></div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class=""> END</div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class=""> ELSIF sym = ORS.procedure THEN ...</div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class=""> ELSE ...</div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class=""> END</div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class=""> END Type0;</div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class=""><br class=""></div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class=""><div class="">I’d be interested if anyone else has bumped into this issue before and whether there are any comments on the proposed solution. In particular, are there any other cases that should be considered and that people have reported before? Also, I have not tested the proposed solution with record extensions.</div><div class=""><br class=""></div></div><div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px;" class=""><div class=""><div class="">Best regards,</div><div class="">AP</div><div class=""><br class=""></div><div class=""><br class=""></div></div></div></body></html>