07-19-2012 08:16 PM
I am helping a customer port their Fortran applications from OpenVMS Alpha V7.2-2 to OpenVMS IA64 V8.4.
The code (mostly) compiles cleanly but some programs are giving wrong results. For example, when compiling and running the attached file (TMINUSPLUS.FOR) we get wrong values displayed:
$ sho sym fortran %DCL-W-UNDSYM, undefined symbol - check validity and spelling $ fortran tminusplus $ link tminusplus $ run tminusplus 18 20 20 18 20 20 $
The value being output by the program should be '20' on every line; '18' is incorrect.
It looks like the compiler is evaluatiing the expression
result = FILE.INFO.SEG(1).END - FILE.INFO.SEG(1).START + 1
as if it was written
result = FILE.INFO.SEG(1).END - (FILE.INFO.SEG(1).START + 1)
and in fact the erroneous instruction, as seen in the Debugger, is
sub r9 = r9, r10, 1
The trailing ", 1" has the effect of subtracting 1 from the result, whereas the expression requires 1 be added to the result.
I've tried both the Fortran 8.2 compiler and the 8.2 ECO1 compiler and both give the same results.
I am going to try to report this to HP. If anyone has seen this before, and/or knows a workaround (which hopefully doesn't require extensive code changes!) I'd like to know about it.
07-20-2012 01:07 AM
I tried this on alpha (8.4) with the same result (error)
Hp Fortran v8.2-104679-48H9K
If I use the old f77 compiler (fortran/old) the result is correct (all 20s)
HP Fortran 77 V7.6-198-48H9K (this version reports 7.6 while it really is the 8.2 version, another bug)
07-20-2012 03:35 AM
07-20-2012 06:28 AM
You could be right, but the image is installed from the fortran 8.2 kit. This kit installs both the fort$main as the f90$main. I find it highly confusing. If they wat to distribute different version for the f90 and the f77 compiler they should have deliverd 2 kits. As far aas I rmember the 8.1 kit distributes an 8.1 version for both compilers.
07-20-2012 08:57 AM
It worked correctly under the Fortran 95 compiler on a much older Alpha version - running OpenVMS Alpha V7.3-2 and Fortran V7.5-1961-48BCD
07-23-2012 02:58 PM
If only all "I've found a compiler bug" reports were so well researched, characterised and documented with such a simple and unarguable reproducer! :-)