g_harrison@vger.nsu.edu (George C. Harrison, Norfolk State University) (06/29/91)
A student has been crying the blues because he code works on Turbo Pascal and not on VAX Pascal. It is totally ISO standard. His program contains code similar to program TEST; type PTR = ^NODE; NODE = record DATA : INTEGER; NEXT : PTR end; var P, TEMP : PTR; begin new(P); TEMP := P; DISPOSE(P); DISPOSE(TEMP) end. Apparently TP (of which I am NOT an expert) allows for a program to dispose of the nodes pointed to by P and TEMP even though the nodes are at exactly the same location. On the other hand, VAX Pascal gives the following RUN-TIME error: PAS-F-ERRDURDIS, error during DISPOSE %TRACE-F-TRACEBACK, symbolic stack dump follows module name routine name line rel PC abs PC 00021361 00021361 TEST TEST 13 00000020 00000220 Is this of any significance? George C. Harrison, Professor of Computer Science Norfolk State University, 2401 Corprew Avenue, Norfolk VA 23504 Internet: g_harrison@vger.nsu.edu Phone: 804-683-8654
dmurdoch@watstat.waterloo.edu (Duncan Murdoch) (06/29/91)
In article <1144.286c2900@vger.nsu.edu> g_harrison@vger.nsu.edu (George C. Harrison, Norfolk State University) writes: >A student has been crying the blues because he code works on >Turbo Pascal and not on VAX Pascal. It is totally ISO standard. >His program contains code similar to > >program TEST; >type PTR = ^NODE; > NODE = record > DATA : INTEGER; > NEXT : PTR > end; >var > P, TEMP : PTR; >begin > new(P); > TEMP := P; > DISPOSE(P); > DISPOSE(TEMP) >end. > >Apparently TP (of which I am NOT an expert) allows for a program to >dispose of the nodes pointed to by P and TEMP even though the nodes >are at exactly the same location. Is that really allowed by the standard? TP version 6 catches it as a run-time error 204, invalid pointer operation. Duncan Murdoch
John G. Spragge <SPRAGGEJ@QUCDN.QueensU.CA> (06/30/91)
[ about disposing of two pointers that refer to the same object ] a) what version of Turbo are you using? What you describe certainly won't work on any recent versions of Turbo Pascal. b) How sure are you what the code is really doing? You may be "disposing" the wrong variable; you may even be messing up random memory. Even if the system accepts the double dispose, I suggest it's a very dangerous thing to do. disclaimer: Queen's University supplies me with computer services, not my opinions. John G. Spragge