NOT = ZEROS test differs between 7.x and 8.0.0 on PIC S9(7) TRAILING SEPARAT



After upgrade from 7.0 to 8.0 problems with signed numeric fields that have a value of zero have been encountered.

Here is the situation:

A numeric field is defined as PIC S9(7) TRAILING SEPARATE.

In this particular data file the value is zero, when viewing this field in the debugger in hex it's value is 30303030 30303030

The program has this statement:


In version 7 the above statement is not true because the value of that field is zeros.  

Now compile the program using version 8 and run with version 8 runtime the above statement is true.  This is causing programs to break.


01 NUM-FIELD    PIC S9(7) TRAILING SEPARATE.  (hex value 30303030 30303030)

Here is an example of how version 8 reacts to these statements compared to version 7.

IF NUM-FIELD = ZEROS  (version 7 says YES, version 8 says YES)

IF NUM-FIELD NOT = ZEROS (version 7 says NO, version 8 says YES)

IF NUM-FIELD < ZEROS (version 7 says NO, version 8 says NO)

IF NUM-FIELD > ZEROS (version 7 says NO, version 8 says NO)


There are 3 work arounds to resolve this problem:

1) use the -C70 compiler option

2) use the -Z70 compiler option

3) use the -Zz compiler option

the suggested work around is #1 (-C70) since this allows use of new syntax or controls implemented in versions later than 7.x.

The -Z70 compiler option, while resolving the problem, restricts the compiler to using syntax, functionality and/or controls that existed in version 7.x and earlier.

The -Zz compiler option turns off optimization by the compiler and the resulting code, while behaving correctly, could perform less efficiently and impact performance.



Old KB# 2724
Comment List