W3cubDocs

/GNU Fortran 7

6.1.29 Bitwise logical operators

With -fdec, GNU Fortran relaxes the type constraints on logical operators to allow integer operands, and performs the corresponding bitwise operation instead. This flag is for compatibility only, and should be avoided in new code. Consider:

INTEGER :: i, j
i = z'33'
j = z'cc'
print *, i .AND. j

In this example, compiled with -fdec, GNU Fortran will replace the .AND. operation with a call to the intrinsic IAND function, yielding the bitwise-and of i and j.

Note that this conversion will occur if at least one operand is of integral type. As a result, a logical operand will be converted to an integer when the other operand is an integer in a logical operation. In this case, .TRUE. is converted to 1 and .FALSE. to 0.

Here is the mapping of logical operator to bitwise intrinsic used with -fdec:

Operator Intrinsic Bitwise operation
.NOT. NOT complement
.AND. IAND intersection
.OR. IOR union
.NEQV. IEOR exclusive or
.EQV. NOT(IEOR) complement of exclusive or

© Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gfortran/Bitwise-logical-operators.html