Skip to content

[flang] Incorrect diagnostic on NULL intrinsic #163255

@DanielCChen

Description

@DanielCChen

Consider the following code:

module m
    type base
        real(4) data
    end type

    interface operator (==)
        logical(4) function equal (b1, b2)
        import
            class (base), pointer, intent(in) :: b1, b2
        end function
    end interface
end module

program fclass022
use m
    class(base), pointer :: b1, b2

    nullify (b1, b2)

    if (b1 == null(b1)) ERROR STOP 3
end

Flang complains:

error: Semantic errors in t.f
./t.f:20:9: error: A NULL() pointer is not allowed as an operand here
      if (b1 == null(b1)) ERROR STOP 3
          ^^^^^^^^^^^^^^
./t.f:20:15: error: NULL() may not be used as an expression in this context
      if (b1 == null(b1)) ERROR STOP 3
                ^^^^^^^^

All gfortran, ifort and XLF accepts the code.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions