Skip to content

[flang] ASSERTION when module and the main program are in two different files. #143740

Open
@DanielCChen

Description

@DanielCChen

File mod.f

module m
type::base
integer(4)::id
contains
procedure::print=>printbase
end type
private::printbase
interface
subroutine printbase(b)
import::base
class(base),intent(in)::b
end
end interface
end

File main.f

module m1
use m
    type, extends (base) :: child
        character*20 :: name = ''

        contains

        procedure :: print => printChild
    end type

    contains

    subroutine printChild (b)
        class (child), intent(in) :: b

        print *, b%id, b%name
    end subroutine
end module

program ftpbnd509a1
use m1
    type (base), target :: b1
    type (child), target :: c1

    class (base), pointer :: b_ptr


    c1 = child (20, 'c1_test')

end

Flang asserts as:

Assertion failed: isa<To>(Val) && "cast<Ty>() argument of incompatible type!", file  llvm-project/llvm/include/llvm/Support/Casting.h, line 572, decltype(auto) llvm::cast(From &) [To = fir::RecordType, From = mlir::Type]()
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /home/cdchen/FLANG/build/bin/flang -fc1 -triple powerpc64-ibm-aix7.2.0.0 -emit-obj -ffree-form -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -target-cpu pwr7 -resource-dir /home/cdchen/FLANG/build/lib/clang/21 -mframe-pointer=all -o ftpbnd509a1.o -x f95 ftpbnd509a1.f
flang-21: error: unable to execute command: IOT/Abort trap

If I move the code in mod.f into main.f, it compiles successfully.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions