Re: D3/Linux compile question



On Feb 19, 1:36 pm, Tony Gravagno
<address.is.in.po...@xxxxxxxxxxxxxxxxxxxxxx> wrote:
Let's settle this once and for all.  In short the Pick flavors do not
consider zero a valid array element while the Prime flavors do.  All
platforms catch non-zero array out of bound issues, though some catch
them in the compiler and others catch them in the runtime.:

01 DIM ARRAY(2)
02 EQUATE ZERO TO ARRAY(0)
03 FOR N = 0 TO 2
04   ARRAY(N) = N+10
05 NEXT N
06 CRT ARRAY(0)
07 CRT ARRAY(1-1)
08 CRT ARRAY(2+1)
09 CRT ARRAY(5+N)
10 CRT ZERO
11 CRT ARRAY(1)
12 CRT ARRAY(2)
13 CRT ARRAY(3)

D3 unflashed and flashed:
Compiler catches line 6 and 13 as subscript out of range.
Runtime catches line 4 as subscript out of range.
Change N to start at 1 and line 7,8,9 get the subscript error, then
line 10 gets a var unassigned.

So the D3 compiler misses the equate but catches the assignment.  This
is a minor bug but it is consistent with D3 compilation of the EQUATE
statement, which as discussed earlier.  The ARRAY(0) reference is not
embedded in the source and then compiled, so the compiler doesn't
catch it in that way.  Note that the D3 Ref also documents the B
option on the compiler to ignore bounds checking but it doesn't seem
to work - I didn't do rigorous testing (= free QA).

jBase: Zero is not valid.
Compiler catches subscript error in 6,7,8,10,13. Impossible to catch 9
at compile time unless N is a constant.
Runtime catches 4 and 9.
Misses equate like D3 but otherwise the compiler was very helpful in
catching errors.

Unidata BasicType P: Zero is not valid.
Compiler doesn't flag anything.
Runtime catches 4,6,7,8,9,10,13.
Misses equate like D3.  The Unidata P type compiler is useless in
detecting array errors that may get into the field.

Universe in Pick flavor account: Zero is not valid
Compiler flags 6,10,13.
Runtime catches 4,7,8,9

QM: Zero is valid.
Runtime catches 8,9,13
However, with $MODE PICK.MATRIX the runtime also catches 4,6,7,10.
Note (as I understand QM) that Option settings don't affect $MODE
settings, so even with OPTION PICK you still need PICK.MATRIX and
others.

Unidata BasicType U: Zero is valid.
No compile errors
Runtime catches 8,9,13.

Universe in Ideal flavor account: Zero is valid.
No compile errors
Runtime catches 8,9,13.

Did not check Caché, Reality, OpenInsight, or any others.

I did this research for these reasons:
1) To answer the questions.
2) To help anyone porting code among these popular environments.
3) To get practice quickly porting code for testing.
4) To demonstrate the value of the Research side of Nebula Research
and Development.  If this information was helpful please consider
Nebula R&D for similar research help you make your decisions, assist
with your quality assurance process, or benchmark or do other testing
to support your development, sales, or marketing efforts.

Tony Gravagno
Nebula Research and Development
TG@ remove.pleaseNebula-RnD.com

Tony,

Thanks for the whack o' information.

Further testing reveals that the compiler may actually be creating
variable space before the actual array area. I dumped the compile
code and that what it looks like to me. Although I'm not at all
familiar with the interanls.

I updated my program and found the following:

01 dim x(5,4)
02 equate a to x(3,0)
03 equ b to x(1,1)
04 equ c to x(2,2)
05 equ d to x(3)
06 equ e to x(4)
07 equ f to x(5)
08
09 for i = 1 to 5
10 for j = 1 to 4
11 x(i,j) = i:",":j
12 next j
13 next i
14 crt a
15 crt b
16 crt c
17 crt d
18 crt e
19 crt f
20 a = 'test this'
21 crt x(2,4)
dlb.bp 'tteesstt' size = 249 filed
tteesstt
...
[820] Creating FlashBASIC Object ( Level 0 ) ...
[241] Successful compile! 2 frame(s) used.
2,4 <- crt A
1,1
2,2
3,1 <- crt of single dimensioned equates
4,1
5,1
test this <- crt x(2,4)

Using the A option in the compile show that the compiler adds the ,1
for d, e, and f. I do believe the compiler does this for single
dimensioned arrays as well.

So the answer to my original question:
Does the compiler ignore the statement: EQU A to x(0)

The answer is no. It creates a variable space before the start of
the array. (I think)

So now the question is:
Is there a whay to have the statement: EQU A to X(0) create a
discriptor (?? is that the right word??) that uses another variable's
location or messes things up in general.

With double dimensioned arrays the answer is yes, as my program has
shown, but I haven't yet found a way with single dimensioned arrays.

Regards,

Dale
.



Relevant Pages

  • Re: D3/Linux compile question
    ... consider zero a valid array element while the Prime flavors do. ... 02 EQUATE ZERO TO ARRAY ... 07 CRT ARRAY ... Compiler catches line 6 and 13 as subscript out of range. ...
    (comp.databases.pick)
  • Re: D3/Linux compile question
    ... His secret was he started counting at zero. ... base frame not 1 past the base frame. ... I just give the compiler what it wants, ... As far as EQU VAR TO ARRAY(0), when we know the first index into ARRAY ...
    (comp.databases.pick)
  • Re: Array syntax
    ... But after I turned on array bounds checking, the absoft compiler ... started printing warning messages for these zero size ranges. ...
    (comp.lang.fortran)
  • Re: How to initialise arrays to zero?
    ... In the CALL RAZ the array may have 1,2 or more indices!! ... compiler to detect it. ... Elemental Subroutine zero(a) ...
    (comp.lang.fortran)
  • Re: Compile Time Error Checking?
    ... and if the string isn't the correct length have then have the compiler ... declare an array of 1 position like this ... size or zero. ...
    (comp.lang.c)