Skip to content

[flang] Defined assignment issue. #153132

@DanielCChen

Description

@DanielCChen

Consider the following reducer:

module m
    type base
        real, allocatable :: data
        contains

        procedure :: uncommonAssgn
        generic :: assignment(=) => uncommonAssgn
    end type

    contains

    !! this is rather unusual way to do assignment: choose the larger value
    !between LHS and RHS for components
    subroutine uncommonAssgn (b1, b2)
        class(base), intent(inout) :: b1
        class(base), intent(in) :: b2

print*, b1%data                     !! Should print 10.1
    end subroutine
end module

module m1
use m
    type container
        type(base) data
    end type

    contains

    subroutine assgnCo (co1, co2)
        type(container), allocatable :: co1
        type(container) co2

        co1 = co2
    end subroutine
end module

program dummyArg009
use m1
    type(container), allocatable :: co1, co2

    allocate (co1,co2)

    co1%data%data = 10.1

    !! test 2
    call assgnCo (co1, co2)
end

Flang's output

> a.out
 0.

Expected output:

>a.out
10.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    flang:frontendquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions