Re: [ooc-compiler] Unsafe pointers on the stack
Brought to you by:
mva
|
From: August K. <fus...@co...> - 2005-05-28 01:55:51
|
Stewart Greenhill wrote: > > Hi August, > >> If I compile and run the following program I get a segmentation fault >> rather that a run time exception. >> >> MODULE Test; >> PROCEDURE P; >> VAR p: POINTER TO ARRAY OF LONGINT; >> BEGIN >> p[0] := 1 >> END P; >> BEGIN >> P >> END Test. >> >> So in this regard the above program compiled with OOC is just as >> unsafe as a C program. Wasn't the elimination of wild pointers one of >> the design criteria of Oberon? > > > OOC generates the following warning for this code. > > In file src/Test.Mod: > PROCEDURE P; > VAR p: POINTER TO ARRAY OF LONGINT; > BEGIN > p[0] := 1 > #--------^ > # 5: Warning: Undefined variable > END P; > BEGIN > P > > OOC V1 used to support the optional initialisation of stack-based > variables (obviously, with a performance cost) via the "Initialize := > TRUE" pragma. I'm not sure if this feature made it into the V2 compiler. > Generally, if you check the compiler warnings it will pick up most of > these cases. > > Cheers, > Stewart > > OK, thanks. Maybe a warning is enough. -- august |