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

    <tr>
        <th>Summary</th>
        <td>
            clang: Assertion `Diagnosed && "failed to diagnose bad conversion"' failed
        </td>
    </tr>

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

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

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

<pre>
    Compiler explorer: https://godbolt.org/z/j8arb77hG.

The following program `small.c` triggers a crash in clang-18:

``` sh
% cat small.c
int f4() {
  #pragma omp task affinity (iterator (int *p = 23 : h) : a);
}


% clang -O0 -fopenmp-simd small.c
<source>:2:54: error: use of undeclared identifier 'h'
    2 |   #pragma omp task affinity (iterator (int *p = 23 : h) : a);
      | ^
<source>:2:49: error: incompatible integer to pointer conversion converting 'int' to type 'int *' [-Wint-conversion]
 2 |   #pragma omp task affinity (iterator (int *p = 23 : h) : a);
 |                                                 ^~
clang: /root/llvm-project/clang/lib/Sema/SemaExprCXX.cpp:4273: clang::ExprResult clang::Sema::PerformImplicitConversion(clang::Expr*, clang::QualType, const clang::ImplicitConversionSequence&, clang::Sema::AssignmentAction, clang::Sema::CheckedConversionKind): Assertion `Diagnosed && "failed to diagnose bad conversion"' 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: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-9.2.0 -fcolor-diagnostics -fno-crash-diagnostics -O0 -fopenmp-simd <source>
1.  <source>:2:57: current parser token ':'
2.  <source>:1:10: parsing function body 'f4'
3.  <source>:1:10: in compound statement ('{}')
 #0 0x000000000372dd18 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x372dd18)
 #1 0x000000000372b9dc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x372b9dc)
 #2 0x00000000036742f8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f56fc333420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f56fbdf600b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #5 0x00007f56fbdd5859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #6 0x00007f56fbdd5729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #7 0x00007f56fbde6fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #8 0x000000000651c947 clang::Sema::PerformImplicitConversion(clang::Expr*, clang::QualType, clang::ImplicitConversionSequence const&, clang::Sema::AssignmentAction, clang::Sema::CheckedConversionKind) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x651c947)
 #9 0x000000000678de13 clang::Sema::PerformImplicitConversion(clang::Expr*, clang::QualType, clang::Sema::AssignmentAction, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x678de13)
#10 0x0000000006446473 clang::Sema::ActOnOMPIteratorExpr(clang::Scope*, clang::SourceLocation, clang::SourceLocation, clang::SourceLocation, llvm::ArrayRef<clang::Sema::OMPIteratorData>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6446473)
#11 0x0000000005f4e2f7 clang::Parser::ParseOpenMPIteratorsExpr() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f4e2f7)
#12 0x0000000005f4fb7f clang::Parser::ParseOpenMPVarList(llvm::omp::Directive, llvm::omp::Clause, llvm::SmallVectorImpl<clang::Expr*>&, clang::Sema::OpenMPVarListDataTy&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f4fb7f)
#13 0x0000000005f503c6 clang::Parser::ParseOpenMPVarListClause(llvm::omp::Directive, llvm::omp::Clause, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f503c6)
#14 0x0000000005f506a8 clang::Parser::ParseOpenMPClause(llvm::omp::Directive, llvm::omp::Clause, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f506a8)
#15 0x0000000005f5c7b8 clang::Parser::ParseOpenMPDeclarativeOrExecutableDirective(clang::Parser::ParsedStmtContext, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f5c7b8)
#16 0x0000000005f792e4 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f792e4)
#17 0x0000000005f7b188 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f7b188)
#18 0x0000000005f7c0c9 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f7c0c9)
#19 0x0000000005f7d9ea clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f7d9ea)
#20 0x0000000005eab6d1 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5eab6d1)
#21 0x0000000005ed2bd8 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5ed2bd8)
#22 0x0000000005e9fb3b clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5e9fb3b)
#23 0x0000000005ea026f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.0) Parser.cpp:0:0
#24 0x0000000005ea7c14 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5ea7c14)
#25 0x0000000005ea843d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5ea843d)
#26 0x0000000005ea8880 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5ea8880)
#27 0x0000000005e9b4b2 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5e9b4b2)
#28 0x00000000049982a8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x49982a8)
#29 0x00000000041fc4f9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x41fc4f9)
#30 0x000000000417d9ce clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x417d9ce)
#31 0x00000000042db54e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x42db54e)
#32 0x0000000000bef0e6 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbef0e6)
#33 0x0000000000be69aa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#34 0x0000000003fd9c19 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#35 0x00000000036747a4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x36747a4)
#36 0x0000000003fda20f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#37 0x0000000003fa23d5 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fa23d5)
#38 0x0000000003fa2e3d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fa2e3d)
#39 0x0000000003faad65 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3faad65)
#40 0x0000000000bec58c clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbec58c)
#41 0x0000000000ae6751 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xae6751)
#42 0x00007f56fbdd7083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#43 0x0000000000be648e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbe648e)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
```

Clang version:

```
clang version 18.0.0 (https://github.com/llvm/llvm-project.git f2b79ed9c6c858426b15a0374103ab901b5b2ef3)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-assertions-trunk/bin
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWs1y4zYSfhr6gqKKBP8PPmgkOzvZSXl27MrmpgJBUEJMAgwAeuQ97LNvAYQkgpY0mh05la1VxRmJABtff93obvwgKemaEXLrJR-8ZHmDerXh4hZzxtZNQ29KXr3eLnjb0YYIQLZdwwURXjQHG6U66UVzD9578H7Nq5I3asbF2oP3__Lg_e85EmWWbX6aecHSC-bD_582BNS8afhXytagE3wtUAu8NJAtapoZ9tIAKEHXayIkQAALJDeAMoAbxNZ-mOsBR-K8NBj-A3Jjn8AEYKTATp55SJkCdezB3IMF8LIPw1MAPBh1Aq1bBHjbAYXkM0B1TRlVr8CDOVVEIMWF-c4U8OC8A160BDAChgIjLpoD5MHCi6xYL1s6EA-wtA7AfwiAX_OOsLbzJW0rF6oXLSTvBSZedOdFc-hF8yTWYxAhuCG-lwTwGvSsIrhBglSAVoQpWlOikWYbD2Y7BQGAwMsW4J1UBeajB_CSu5P448LBTxnmbYcULRsCKFNkTQRQHHRc_xAAc_ZChKSc2a9Ku4oHM8qUBzPdVb12xD7RSPVTL_ng_5My5R9e9xJriHcmYZD9fR8vufv38LrxCi3Ug_eCc-XB-6Z5af1O8N8J1j-HHvC-oaUH7x9Ji-w_d9tOLH77bYa7TtMMs0jL2Qn0ornu8IXIvlHjp0aC-faZiJqL9mPbNRRTtThQB_OJGEPzYizmHz1qnl47Yh5zJp0x3op8JH_0hGHiwXQi6IBnbqJRS5iaY2VgnOi42BD8TKqD9L9TVhmjzMFcSu0znOmwsqRozbgkFTDjpsCDsEa0IZX2o8q2ghJVI7_zINQuNfSz4evzp7v54x2QfdlSBRAo-zUQpONCaUGTYEjVpi9nmLfWmG9tSqX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