Skip to content

[Flang] Compilation abnormally terminates when using concat-op as an argument to adjustr intrinsic function in where construct #122823

@ohno-fj

Description

@ohno-fj
Version of flang : 20.0.0(f4230b4332262dffb0bd3b7a2f8d6deb2e96488e)/AArch64

When using concat-op (//) as an argument to adjustr intrinsic function in where construct, a compilation terminates abnormally (Lowering to LLVM IR failed).
Compilation ends normally in the following cases:

  • Use the adjustr intrinsic function outside where construct
    The above program is sngg4151_21.F.
  • Do not use concat-op in an argument of adjustr intrinsic function
    The above program is sngg4151_22.F.

The following are the test program, Flang, Gfortran and ifx compilation/execution result.

sngg4151_20.F:

      program main
      logical         ,dimension(1):: mask=.true.
      character(len=2),dimension(1):: d1="a "
      character(len=4),dimension(1):: d4
        where (mask)
          d4=adjustr(d1//d1)
        end where
        write(6,*) "d4     =", d4
      end
$ flang sngg4151_20.F
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/MCS/wsf/sngg4151_20.F":6:11): 'fir.convert' op invalid type conversion'!fir.ref<!fir.char<1,4>>' / '!fir.boxchar<1>'
error: Lowering to LLVM IR failed
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/MCS/wsf/sngg4151_20.F":1:7): cannot be converted to LLVM IR: missing `LLVMTranslationDialectInterface` registration for dialect for op: func.func
error: failed to create the LLVM module
$
$ gfortran sngg4151_20.F; ./a.out
 d4     = a a
$
$ ifx sngg4151_20.F; ./a.out
 d4     = a a
$

sngg4151_21.F:

      program main
      logical         ,dimension(1):: mask=.true.
      character(len=2),dimension(1):: d1="a "
      character(len=4),dimension(1):: d4
!        where (mask)
          d4=adjustr(d1//d1)
!        end where
        write(6,*) "d4     =", d4
      end
$ flang sngg4151_21.F; ./a.out
 d4     = a a
$

sngg4151_22.F:

      program main
      logical         ,dimension(1):: mask=.true.
      character(len=2),dimension(1):: d1="a "
      character(len=4),dimension(1):: d4
        where (mask)
          d4=adjustr("a a ")
        end where
        write(6,*) "d4     =", d4
      end
$ flang sngg4151_22.F; ./a.out
 d4     = a a
$

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions