Logical Expressions in Parameter List

Product Version(s): 3.31
Operating System:   MS-DOS
Flags: ENDUSER | buglist3.31
Last Modified: 12-MAY-1988    ArticleIdent: Q11584

Problem:
   There is an inconsistency in the way the compiler evaluates logical
expressions when they are used as parameters in a function call.
   Specifically, if a logical expression involving a real number is
used as a parameter in a function call, it is not properly evaluated
before being passed to the function.
   The following is a program that demonstrates this behavior:

   integer iso
   real riso
   logical chkr,t1,t2
   iso=45
   riso=45.0

   if (chkr(.TRUE.,(riso.ge.0.0), (riso.lt.180.0))) then
   write(*,*) 'real true'
   else
   write(*,*) 'real false'
   endif

   t1=(riso.ge.0.0)
   t2=(riso.lt.180.0)
   if (chkr(.TRUE.,t1,t2)) then
   write(*,*) 'real true'
   else
   write(*,*) 'real false'
   endif

   stop
   end

   logical function chkr(b1,b2,b3)
   logical b1,b2,b3

   chkr=(b1.and.b2.and.b3)
   if (chkr) return
   write(*,*) 'error'
   return
   end

Response:
   Microsoft confirmed this to be a problem in Version 3.31 of the
FORTRAN compiler.
   This problem was corrected in Version 4.00.