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

    <tr>
        <th>Summary</th>
        <td>
            [clang++][OpenMP][Frontend] Assertion failed when compile a OpenMP test case
        </td>
    </tr>

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

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

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

<pre>
    Hi everyone,
I have tryed to reduce my testcase as follows,
``` c++
#include <vector>

int getNum();
extern const int global;

void Test(int task_depth) {
#pragma omp task untied default(shared) \
  final(task_depth >= global) mergeable
  {
 std::vector<float> work2(getNum());
    for (auto& cb : work2)
      cb = 1.0;
    Test(task_depth + 1);
  }
}
```
Here is my compiler info,
```
$ clang++ -v
clang version 15.0.7
Target: aarch64-unknown-linux-gnu
Thread model: posix
```
I tryed llvm 16.0.0 but got building errors when I built it on my system :)

`clang++ test3.cpp -S -fopenmp -O3` shows the following errors,
``` shell
clang++: llvm-project-llvmorg-15.0.7/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From*) [with To = llvm::PointerType; From = llvm::Type]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
...
 #9 0x0000ffffbcdcf7e0 __assert_perror_fail (/usr/lib64/libc.so.6+0x2f7e0)
#10 0x0000000001eec7d0 bool llvm::isa<llvm::PointerType, llvm::Type*>(llvm::Type* const&) llvm-project-llvmorg-15.0.7/llvm/include/llvm/Support/Casting.h:578:0
#11 0x0000000001eec7d0 decltype(auto) llvm::cast<llvm::PointerType, llvm::Type>(llvm::Type*) llvm-project-llvmorg-15.0.7/llvm/include/llvm/Support/Casting.h:578:0
#12 0x0000000001eec7d0 clang::CodeGen::Address::Address(llvm::Value*, llvm::Type*, clang::CharUnits) llvm-project-llvmorg-15.0.7/clang/lib/CodeGen/Address.h:85:0
#13 0x000000000219c280 clang::CodeGen::CodeGenFunction::EmitLoadOfReference(clang::CodeGen::LValue, clang::CodeGen::LValueBaseInfo*, clang::CodeGen::TBAAAccessInfo*) llvm-project-llvmorg-15.0.7/clang/lib/CodeGen/CGExpr.cpp:2570:0
#14 0x000000000219c318 clang::CodeGen::CodeGenFunction::EmitLoadOfReferenceLValue(clang::CodeGen::LValue) llvm-project-llvmorg-15.0.7/clang/lib/CodeGen/CGExpr.cpp:2576:0
#15 0x000000000219c46c clang::CodeGen::CodeGenFunction::EmitLoadOfReferenceLValue(clang::CodeGen::Address, clang::QualType, clang::CodeGen::AlignmentSource) llvm-project-llvmorg-15.0.7/clang/lib/CodeGen/CodeGenFunction.h:2527:0
...
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0lt2S26gSx58G33RZJYMk2xe-kO1xMlU5Jzkns7mdQqglsUGgAjQfb7-FJH9NPJWtzWbK5THQDf370w1w52StETck3ZJ0P-O9b4zdIHd-SxmbFaZ83XyUgE9oX41GQnck3pM4v4eGPyF4-4oleAMWy14gtK_g0XnBHQJ3UBmlzLM7eZEsHj8gCN2Gz9hNmdRC9SUCYbsnFN5Ywu6mweFbag81-v_2LaErQteETb744tFqEEY7D4OVMgVXp_Hx-8nIEh7QeUJXwchz9_2xxM43hK6BLM-BdJbXLQfTdoMR9NpLLKHEivcquLuGWywHt3TCAqik5orQ1XleCABsfwyHrqFFWyMvFB6dTsuC8yVhOWH5kX1XKcM9YXfwbOx3SujqCv6CHwCgMhYIXfHeG0IzEAUQlh8912c7GIf2sIjiqwkmZS6jp1tYXK9DlvtJpdOP43aOzY9oEaQLSSBM20mFFqSuzI_bf1Q7AaG4rsdcgPnT2D_0wRNaJ42GRRrF0XIceeC2Rh_gOLeiyZJ5r79r86znSur-ZV7rfjJsLPISWlOiCuadcfLlZhD3Uw4r9dTCIoviKIai91AbD0UvVSl1DWitsQ6eG9RwP3R7kB6MDqzu1Xlsg-QnsU8rXeKFwmCR6DqYf4V5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