Message-ID: <3BAA1F02.7AB1E05D@yahoo.com.NOSPAM> From: CBFalconer Organization: Ched Research X-Mailer: Mozilla 4.75 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp,comp.lang.pascal.misc,comp.lang.pascal.ansi-iso Subject: Testing GPC under DJGPP Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 126 Date: Thu, 20 Sep 2001 16:53:23 GMT NNTP-Posting-Host: 12.90.167.21 X-Complaints-To: abuse AT worldnet DOT att DOT net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1001004803 12.90.167.21 (Thu, 20 Sep 2001 16:53:23 GMT) NNTP-Posting-Date: Thu, 20 Sep 2001 16:53:23 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com I saw some things in the GPC docs about not overlaying memory areas in variant records, which worried me inasmuch as many programs depend on this for interfacing. So I wrote the following test, which shows that memory *IS* overlaid. However it also shows some other failings in GPC (I set the option to standard-pascal). It is being run from RHIDE under DJGPP, if that matters. I would appreciate hearing from the developers on this. BTW, according to standards a component of a packed array cannot be accessed directly, but must be extracted or inserted with the pack and unpack standard procedures. My PascalP also has this failing. PROGRAM gnuvarnt(input, output); (* Check whether or not variant records access same memory *) TYPE varcd = RECORD CASE 1..4 OF 1: (c : char); 2: (s : PACKED ARRAY[1..8] OF char); 3: (a3 : ARRAY[1..3] OF integer); 4: (a4 : ARRAY[1..4] OF integer); END; VAR vrcd : varcd; i : integer; PROCEDURE showrcd(kind : integer); VAR i : integer; BEGIN (* showrcd *) write('Record type ', kind, ': '); CASE kind OF 1: write(vrcd.c); 2: write(vrcd.s); 3: FOR i := 1 TO kind DO write(vrcd.a3[i] : 12); 4: FOR i := 1 TO kind DO write(vrcd.a4[i] : 12); OTHERWISE write('Bad record kind ', kind); END; writeln; END; (* showrcd *) BEGIN (* gnuvarnt *) writeln; writeln('Testing variant records'); FOR i := 1 TO 4 DO vrcd.a4[i] := i; showrcd(4); writeln; FOR i := 1 TO 3 DO vrcd.a3[i] := -i; showrcd(3); showrcd(4); writeln; vrcd.s := 'Eight ch'; showrcd(2); showrcd(3); showrcd(4); writeln; vrcd.c := 'X'; showrcd(1); showrcd(2); showrcd(3); showrcd(4); writeln; writeln('This should be a compile time error'); vrcd.s[2] := 'Y'; showrcd(2); writeln; writeln('This should fail on index range'); FOR i := 1 TO 4 DO vrcd.a3[i] := i + 10; showrcd(4); writeln('DONE'); END. (* gnuvarnt *) Output, here, is: Testing variant records Record type 4: 1 2 3 4 Record type 3: -1 -2 -3 Record type 4: -1 -2 -3 4 Record type 2: Eight ch Record type 3: 1751607621 1751326836 -3 Record type 4: 1751607621 1751326836 -3 4 Record type 1: X Record type 2: Xight ch Record type 3: 1751607640 1751326836 -3 Record type 4: 1751607640 1751326836 -3 4 This should be a compile time error Record type 2: XYght ch This should fail on index range Record type 4: 11 12 13 14 DONE And the compilation results under PascalP are: [1] c:\p\gnuvarnt>pascalp gnuvarnt.pas gnuvarnt.lst nul PASCALP (pasctext, pasclist, prr, ef, output) [parm] V 3.1.9T 6000 0:d CASE 1..4 OF **** ^2 2. Identifier expected 29000 189: 3 OTHERWISE **** ^118 118. ** WARNING ** Non-standard Pascal feature used NO. ERRORS=1 WARNINGS=1 Program size(pcode bytes)=744 -- Chuck F (cbfalconer AT yahoo DOT com) (cbfalconer AT XXXXworldnet DOT att DOT net) (Remove "XXXX" from reply address. yahoo works unmodified) mailto:uce AT ftc DOT gov (for spambots to harvest)