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

    <tr>
        <th>Summary</th>
        <td>
            Assertion failure in SemaTemplateInstantiate.cpp
        </td>
    </tr>

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

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

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

<pre>
    We seem to be hitting some assertion failures when compiling Fuchsia. 

We have the following backtrace:
```
FAILED: obj/src/lib/fasync/tests/fasync-test.future_tests.cc.o
../../../recipe_cleanup/clangu2e8ti14/bin/clang++ -MD -MF obj/src/lib/fasync/tests/fasync-test.future_tests.cc.o.d -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS=1 -DZX_ASSERT_LEVEL=2 -DFIDL_TRACE_LEVEL=0 -I../.. -Igen -I../../src/lib/fasync/include -I../../sdk/lib/fit/include -I../../sdk/lib/stdcompat/include -I../../zircon/system/ulib/zxc/include -I../../zircon/system/ulib/zxtest/include -Igen/include -I../../src/zircon/lib/zircon/include -I../../zircon/system/ulib/fbl/include -I../../zircon/system/ulib/zx/include -I../../sdk/lib/fdio/include -I../../sdk -Igen/sdk -I../../zircon/system/ulib/syslog/include -fclang-abi-compat=13.0 -fcolor-diagnostics -fcrash-diagnostics-dir=clang-crashreports -ffp-contract=off --sysroot=gen/zircon/public/sysroot/cpp --target=x86_64-unknown-fuchsia -ffuchsia-api-level=7 -march=x86-64-v2 -mtune=generic -mbranches-within-32B-boundaries -ffile-compilation-dir=. -no-canonical-prefixes -fno-omit-frame-pointer -fdata-sections -ffunction-sections -O0 -gdwarf-5 -Xclang -debug-info-kind=constructor -g3 -Wall -Wextra -Wconversion -Wextra-semi -Wimplicit-fallthrough -Wnewline-eof -Wstrict-prototypes -Wwrite-strings -Wno-sign-conversion -Wno-unused-parameter -Wnonportable-system-include-path -fvisibility=hidden -Werror -Wno-error=deprecated-declarations -Wa,--fatal-warnings -ftrivial-auto-var-init=pattern -Wthread-safety -fvisibility-inlines-hidden -std=c++17 -fno-exceptions -fno-rtti -c ../../src/lib/fasync/tests/future_tests.cc -o obj/src/lib/fasync/tests/fasync-test.future_tests.cc.o
clang++: clang/lib/Sema/SemaTemplateInstantiate.cpp:3613: llvm::PointerUnion<Decl *, LocalInstantiationScope::DeclArgumentPack *> *clang::LocalInstantiationScope::findInstantiationOf(const clang::Decl *): Assertion `isa<LabelDecl>(D) && "declaration not instantiated in this scope"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: ../../../recipe_cleanup/clangu2e8ti14/bin/clang++ -MD -MF obj/src/lib/fasync/tests/fasync-test.future_tests.cc.o.d -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS=1 -DZX_ASSERT_LEVEL=2 -DFIDL_TRACE_LEVEL=0 -I../.. -Igen -I../../src/lib/fasync/include -I../../sdk/lib/fit/include -I../../sdk/lib/stdcompat/include -I../../zircon/system/ulib/zxc/include -I../../zircon/system/ulib/zxtest/include -Igen/include -I../../src/zircon/lib/zircon/include -I../../zircon/system/ulib/fbl/include -I../../zircon/system/ulib/zx/include -I../../sdk/lib/fdio/include -I../../sdk -Igen/sdk -I../../zircon/system/ulib/syslog/include -fclang-abi-compat=13.0 -fcolor-diagnostics -fcrash-diagnostics-dir=clang-crashreports -ffp-contract=off --sysroot=gen/zircon/public/sysroot/cpp --target=x86_64-unknown-fuchsia -ffuchsia-api-level=7 -march=x86-64-v2 -mtune=generic -mbranches-within-32B-boundaries -ffile-compilation-dir=. -no-canonical-prefixes -fno-omit-frame-pointer -fdata-sections -ffunction-sections -O0 -gdwarf-5 -Xclang -debug-info-kind=constructor -g3 -Wall -Wextra -Wconversion -Wextra-semi -Wimplicit-fallthrough -Wnewline-eof -Wstrict-prototypes -Wwrite-strings -Wno-sign-conversion -Wno-unused-parameter -Wnonportable-system-include-path -fvisibility=hidden -Werror -Wno-error=deprecated-declarations -Wa,--fatal-warnings -ftrivial-auto-var-init=pattern -Wthread-safety -fvisibility-inlines-hidden -std=c++17 -fno-exceptions -fno-rtti -c ../../src/lib/fasync/tests/future_tests.cc -o obj/src/lib/fasync/tests/fasync-test.future_tests.cc.o
1.      ../../src/lib/fasync/tests/future_tests.cc:954:62: current parser token ')'
2.      ../../src/lib/fasync/tests/future_tests.cc:26:1: parsing namespace '(anonymous)'
3.      ../../src/lib/fasync/tests/future_tests.cc:946:28: parsing function body '(anonymous namespace)::FutureTests_Flatten_Class::TestBody'
4.      ../../src/lib/fasync/tests/future_tests.cc:946:28: in compound statement ('{}')
5.      ../../src/lib/fasync/tests/future_tests.cc:953:3: in compound statement ('{}')
6.      ../../src/lib/fasync/tests/future_tests.cc:939:16: instantiating function definition '(anonymous namespace)::nest_futures<2UL, std::string_view, true>'
#0 0x00000000036c5bdd PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Fuchsia clang version 15.0.0 (https://llvm.googlesource.com/a/llvm-project af0285122f306573d9bcc4c4ad7f904cfdd4d869)
Target: x86_64-unknown-fuchsia
Thread model: posix
InstalledDir: ../../../recipe_cleanup/clangu2e8ti14/bin
clang++: note: diagnostic msg:
```

The reproducers are attached here:
[clang-crashreports.zip](https://github.com/llvm/llvm-project/files/8508327/clang-crashreports.zip)

This first appears in our CI here for arm: https://luci-milo.appspot.com/ui/p/fuchsia/builders/ci/clang_toolchain.ci.core.arm64-release/b8816805158850263105/overview

and here for x86: https://luci-milo.appspot.com/ui/p/fuchsia/builders/ci/clang_toolchain.ci.core.x64-release/b8816803488685972465/overview

Judging by the comments above the assertion at line 3613 of SemaTemplateInstantiate.cpp, this may indicate a more serious bug in Sema.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