[net.lang.pascal] Dangling pointers in Turbo

curtis@uwmacc.UUCP (Alan Curtis) (10/16/85)

*** PARITY ERROR ***
????

I've been using TURBO (V 3.0) on my PC to do some class work, and have
run into a problem whenever I accidentally leave pointers uninitialized
or use pointers that are set to nil.  The problem is that the illegal 
memory reference is never trapped by anything, subsequently the machine
bombs and the only way to restart it is with the big red switch.

A side effect of this is that if I haven't saved the current work file 
since the last change(s), it is lost (this has hurt a couple of times,
and therefore I am quite a bit more careful about saving before every
run).  Also, there is obviously no diagnostic about where the program
was when it went out into never-never land.

My question is: Is this just a result of using a cheap compiler, or
does MS-PASCAL and other "expensive" pascal compilers also suffer the
same problem?

Another question: If other compilers don't fix this problem, will a 
fancy OS (such as XENIX, PCIX, etc) trap these errors and prevent
the machine from going down?

_Alan Curtis
 {allegra, ihnp4, seismo}!uwvax!uwmacc!curtis

rick@uwmacc.UUCP (the absurdist) (10/18/85)

In article <1568@uwmacc.UUCP> curtis@uwmacc.UUCP (Alan Curtis) writes:
>I've been using TURBO (V 3.0) on my PC to do some class work, and have
>run into a problem whenever I accidentally leave pointers uninitialized
>or use pointers that are set to nil.  <...>
>My question is: Is this just a result of using a cheap compiler, or
>does MS-PASCAL and other "expensive" pascal compilers also suffer the
>same problem?

Alan, it is not caused by Turbo being "cheap".  The Pascal compiler for
VM/CMS on an IBM 4341 will give you a lovely error message for a pointer
if you accidentally rearrange your declarations and block structure
(and this is easy with a line-oriented editor):

	Internal Consistency Detected:  Notify your IBM Compiler Support
	Group -- [and then some address in New York ]

	(Isn't this enlightening?)

	This, together with various messages about ABEND, program
aborting, etc.  As my semester project was by this time a 2 and 1/2
inch thick listing, it took me 2 days to find that the damn pointer
declaration had been moved 3 lines higher, outside of any block.
Moving it back fixed the problem.  Turbo, on the other hand, would
have flagged a syntax error on the first compilation.
-- 
Rick Keir -- right next to the Oyster Tank -- UWisc - Madison
{allegra, ihnp4, seismo}!uwvax!uwmacc!rick

uh@unido.UUCP (10/19/85)

As much as I know, Mr Wirth in Zurich never said anything about waht
should happen, if pointers are not initialized. I know some more
compilers who run into difficulties if you use illegal pointer
references. (I think the UCSD compilers belong to this class too).
On the other hand a NIL initaliezed pointer should not perform any
curios things. In this case it is a compiler or run-time-system
error, I think. 

Trapping such illegal memory references should be the task of the
OS or the processor, either which one is better prepared for this task.
Only in cases the processor and the OS are not able to do this, the run-
time-system of the compiler should take over this task (especially on
8-bit systems).

I'm too working very much with Turbo 3.0, but only sometimes with pointers,
and also I always initialize all (!!!!) my variables, because only few
pascal compilers do that for me. Always remember: N. Wirth said nothing
about initalizing in his User Manual and Report.

     Uwe Hoch
     Computer Science Department, University of Dortmund
     4600 Dortmund 50, P.O. Box 500500, W.-Germany
     E-mail address UUCP: ...ihnp4!{hpfcla!hpbbn,mcvax}!unido!uh