5.1.30 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 replaces the .AND. operation with a call to the intrinsic IAND — Bitwise logical and function, yielding the bitwise-and of i and j.

Note that this conversion occurs if at least one operand is of integral type. As a result, a logical operand is 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:

OperatorIntrinsicBitwise operation
.NOT.NOTcomplement (see NOT — Logical negation)
.AND.IANDintersection (see IAND — Bitwise logical and)
.OR.IORunion (see IOR — Bitwise logical or)
.NEQV.IEORexclusive or (see IEOR — Bitwise logical exclusive or)
.EQV.NOT IEORcomplement of exclusive or (see IEOR — Bitwise logical exclusive or)