<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/122823>122823</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Flang] Compilation abnormally terminates when using concat-op as an argument to adjustr intrinsic function in where construct
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang:ir
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ohno-fj
      </td>
    </tr>
</table>

<pre>
    ```
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:
```fortran
      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:
```fortran
      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:
```fortran
      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
$
```

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkV01z2zYQ_TWrC8YccEFJ1EEHRio76SSX1k2PHRBYSkhIQAOAdvLvOyApWUqaz3p6CYdjkwT27cN-PK9lCOZgibawfAHL_UIO8ej81h2tu2vfLhqnP2xhxeebV2_IB-Mscy1rO2kPDETFkGc844BlW6DgTSEE4gp12za80aJZS2xLvdLUIG1WRVkS4AawriqvjqsCeHXtAXj115EsG4JJ8CuunFUy3rkTAywB6_HewIozGZi0TPrD0JONLLq0Xeq3Q4g-rRsbvbHBKNYOVsXE29i05_FIntIO5WyIflARcMckU64_mU6OOyP53lgZKTDZWOd72XUfEoVX7pF84hYde_XqzWv28nfWStORBtxkDHi1u4IhqwO7mBvL4pFY67rOPSYMJQMFEOnUd-zPQOPyV0_hhhiMpn8_CksUGLs_EpONeyB28u7gZc9MSAbBHg5Fvsz_xjyrYcWz0fXeMesiGwLdhHzyfxNl136d37cywAsD4NX9TWCkn2IRKcSzfUpSnaouPfzaOh99YmY1M-376-QB1vSe1DCS8RSGLs5OnnzzrJ7ifim-GXDknq4z616ap4-dOxglOwa406YnG0Z3ZZ5KUlSpG3oZ3oHYZ9EPlF3s1FF6qSJ5wLIjC2KPYxd8DkXnIPaAKBkgfgGl-DJKcTFlbCyVVMEjQ9ykJV2A2J-TiaXOpwbT-bw-X2T1ZH4N500kwHIFuAOsADeJqi7GxYl8ytNEgaz-tM9vXrGYFeU2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