Thread View: comp.lang.oberon
2 messages
2 total messages
Started by MWeiss
Wed, 10 Apr 1996 08:25
(no subject)
Author: MWeiss
Date: Wed, 10 Apr 1996 08:25
Date: Wed, 10 Apr 1996 08:25
41 lines
1219 bytes
1219 bytes
Execution of Test.Do in the following sample module generates a "NIL dereference read " trap on Oberon/F at the line indicated although in Oberon for Windows V4, it works all fine. MODULE Test; TYPE T0 = POINTER TO T0desc; T0desc = RECORD next: T0; END; T1 = POINTER TO T1desc; T1desc = RECORD(T0desc) END; PROCEDURE Do*; VAR x: T1; next: T0; BEGIN NEW(x); x := x.next(T1); (* a TRAP is generated here *) END Do; END Test. It seems that type-guarding the pointer x.next which happens to have the value NIL at execution time causes the problem. Did anybody else encounter this problem before? I am using Oberon/F v 1.1 for Windows. Thank you in advance for any hints. Martin Weiss Applied Physics Faculty University of Eindhoven The Netherlands
Re: (no subject)
Author: Stephan Gehring
Date: Wed, 10 Apr 1996 10:31
Date: Wed, 10 Apr 1996 10:31
35 lines
1501 bytes
1501 bytes
In article <4kfra6$k1t@tuegate.tue.nl>, MWeiss <MartinW@ctrl.phys.tue.nl> wrote: >MODULE Test; > .... > >PROCEDURE Do*; > VAR x: T1; next: T0; >BEGIN > NEW(x); > x := x.next(T1); (* a TRAP is generated here *) >END Do; > >END Test. > >It seems that type-guarding the pointer x.next which happens to >have the value NIL at execution time causes the problem. Did >anybody else encounter this problem before? Yes. NEW (x) obviously initializes x.next to NIL. You cannot type-guard a pointer whose value is NIL. Therefore the trap. You must always ensure that the pointer being guarded is not NIL before guarding it, e.g. IF x.next # NIL THEN x := x.next(T1) END > >I am using Oberon/F v 1.1 for Windows. You'll find this behaviour in all (?) Oberon implementations -Stephan ------------------------------------------------------------------------------ Stephan Gehring Email: gehring@inf.ethz.ch Institute for Computer Systems Phone: +41 1 632 73 15 ETH-Zentrum FAX: +41 1 632 13 07 CH-8092 Zurich, Switzerland
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads