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

    <tr>
        <th>Summary</th>
        <td>
            [flang] recently implemented OpenMP reduction construct apparently has a bug, trivial reproducer
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          keidavis
      </td>
    </tr>
</table>

<pre>
    
> flang-new -c -o test6.o test6.f90 -fopenmp

flang-new: /home/kei/flang/llvm-project/llvm/include/llvm/Support/Casting.h:566: decltype(auto) llvm::cast(const From&) [with To = fir::ReferenceType; From = mlir::Type]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.

[lots more stuff, in attached stacktrace.txt file]

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
flang-new: note: diagnostic msg: /tmp/test6-3abc4c
flang-new: note: diagnostic msg: /tmp/test6-3abc4c.sh

Yeah, well, I haven't done this before and this won't let me load these files, but there's enough info below. Am I missing something or are the instructions out of date?

[stacktrace.txt](https://github.com/llvm/llvm-project/files/13865857/stacktrace.txt)

$ flang-new --version
flang-new version 18.0.0git (https://github.com/llvm/llvm-project.git b4ee7d6119f97931d9f38ac8c6bc7409eed87aab)
Target: x86_64-unknown-linux-gnu
Thread model: posix

Invocation:

$ flang-new -c -o test6.o test6.f90 -fopenmp

Reproducer:

MODULE repro_mod

    USE omp_lib

    IMPLICIT NONE

CONTAINS

  SUBROUTINE repro_tine(l, fa, fac)
 INTEGER, INTENT(IN) :: l, fac
    double precision, INTENT(OUT) :: fa(l*fac)

!$omp parallel &
!$omp   shared(l,fac)   &
!$omp   reduction(+:fa) 


!$omp end parallel

  END SUBROUTINE repro_tine

END MODULE repro_m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