Skip to content

[flang] Unlimited polymorphic argument for intrnsic MERGE caused FIR verification failure #143582

@DanielCChen

Description

@DanielCChen

Consider the following code:


  type base
    real :: r1
  end type

contains
  SUBROUTINE Sub(Arg1, Arg2)
  !CLASS(base) :: Arg1(:, :), Arg2(:, :)                       !! Workaround
  CLASS(*) :: Arg1(:, :), Arg2(:, :)
  LOGICAL :: Mask(2, 2) = .true.

  SELECT TYPE ( V=>MERGE(Arg1, Arg2, Mask) )
    CLASS DEFAULT
      print*, "in class default"
  END SELECT

  END SUBROUTINE
end

Flang fails at the compile time with

error: loc("/home/cdchen/temp/SltArrFuncPolyPtr.f":11:3): nonscalar intrinsic argument
LLVM ERROR: aborting
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 /tmp/SltArrFuncPolyPtr-81bc14.o -x f95 SltArrFuncPolyPtr.f
flang-21: error: unable to execute command: IOT/Abort trap
flang-21: error: flang frontend command failed due to signal (use -v to see invocation)
flang version 21.0.0git ([email protected]:DanielCChen/llvm-project.git b896d262ebc530a92327b912b2bd5ac3b0bb0e56)
Target: powerpc64-ibm-aix7.2.0.0
Thread model: posix
InstalledDir: /home/cdchen/FLANG/build/bin
Build config: +assertions
flang-21: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
flang-21: note: diagnostic msg: /tmp/SltArrFuncPolyPtr-0a9010
flang-21: note: diagnostic msg: /tmp/SltArrFuncPolyPtr-0a9010.sh
flang-21: note: diagnostic msg:

If I use the workaround marked in the code, it compiles successfully.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions