Skip to content

[Flang] Incorrect diagnose on NULL(mold) actual to allocatable dummy #115984

@DanielCChen

Description

@DanielCChen

Consider the following code:

module m
    type Base
        integer i
    end type

    type, extends(Base) :: Child
        integer j
    end type
end module

program argAssociation001
use m
    type(Child), allocatable :: c

    allocate(c, SOURCE=Child(2,-2))
    call sub1(null(c))

    contains
    subroutine sub1(arg)
        type(Child), allocatable :: arg
    end subroutine
end

Flang issues an error as

t2.f:16:15: error: A null pointer may not be associated with allocatable dummy argument 'arg=' without INTENT(IN)
      call sub1(null(c))

The code seems conforming to me as I can't find such constraint in the standard.
Both XLF and ifort compile the code successfully.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions