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

    <tr>
        <th>Summary</th>
        <td>
            `__builtin_addressof` can't handle overloaded functions
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    ```c++
void a(int) {}
void a(float) {}

constexpr int A = __builtin_addressof(a);
```

results in :

```console
<source>:4:39: error: reference to overloaded function could not be resolved; did you mean to call it?
    4 | constexpr int A = __builtin_addressof(a);
      | ^
<source>:2:6: note: possible target for call
    2 | void a(float) {}
      |      ^
<source>:1:6: note: possible target for call
    1 | void a(int) {}
      |      ^
clang++: /root/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From*) [with To = clang::OverloadExpr; From = clang::Expr]: 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, 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-snapshot -fcolor-diagnostics -fno-crash-diagnostics <source>
1.      <source>:4:41: current parser token ';'
 #0 0x0000000003800088 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3800088)
 #1 0x00000000037fdd5c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x37fdd5c)
 #2 0x0000000003746f38 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f7e68e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f7e68e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007f7e68e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007f7e68e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00007f7e68e2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x00007f7e68e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x00000000061b61a7 clang::OverloadExpr::find(clang::Expr*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x61b61a7)
#10 0x0000000006908ed0 clang::Sema::ResolveAddressOfOverloadedFunction(clang::Expr*, clang::QualType, bool, clang::DeclAccessPair&, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6908ed0)
#11 0x000000000690b5e2 IsStandardConversion(clang::Sema&, clang::Expr*, clang::QualType, bool, clang::StandardConversionSequence&, bool, bool) SemaOverload.cpp:0:0
#12 0x00000000069199ee TryImplicitConversion(clang::Sema&, clang::Expr*, clang::QualType, bool, clang::Sema::AllowedExplicit, bool, bool, bool, bool) SemaOverload.cpp:0:0
#13 0x0000000006919d12 clang::Sema::TryImplicitConversion(clang::Expr*, clang::QualType, bool, clang::Sema::AllowedExplicit, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6919d12)
#14 0x000000000677ac8e clang::InitializationSequence::InitializeFrom(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x677ac8e)
#15 0x000000000637c029 clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x637c029)
#16 0x000000000603e893 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x603e893)
[...]
```

See: https://godbolt.org/z/WejE5zfMT
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8WFtz4joS_jXiRWXKSMaXBx4cEmqndk9NdpLafUzJUht0IiSvJCcwv35LMgRMktnNnMmkmMHo0v3111_rYuacXGuABZpfofn1hPV-Y-zCNwwEWDtpjNgvUJ4OH47IVfik1yitn4wUmCFSSu0RqTAqrlBxfdHXKsNe9Q7_c6Odh11nsdQe1xjRa_zw0PRSeakfmBAWnDMtIiVDpEL04PYFzLktC65X3mGpMaL1ec8Ju9HOKDi00qUzveWA6A2idYZoTStEawzWGhseLLRgQXPA3mDzBFYZJkDgttfcS6MxN70SWBuPG8AWnFFPIBC9wkIKvDc93gLTYTJnSmHpEV0NvjHGOMOoWOKfZADHv2AAzW_ejIcgWuchCm08hO_OOCcbBdgzuwaPW2MjrpNBEg3-OG8nx8PDO95nH_c-G3t_Q1Hv-eaK6fVBlrTGiKysMR6RlVJP26Sz5k_gx5-IrKTmqhdwarjru87YMGLJnJd6Pd0gWs-LMlgTwJXfdxAy0HsTMMVptEa05sx5RMqVNVtE6oh3fvUs_Qbfm5jKAVoc-_UgoJtdZ4NGwqTLMbFvfh381s6BjSpDeSodQ3R5bwK5pPwXU9EVyRHJMSIkwqDL-_3QHzqZXfdb0B6bFkvNzbZjfuA_xjJDhCBS4JZJBWI68Hj7j5v67ga7vtlKjxlu-jW2EKgJGt5437kAk6wQWa2l3_TNlIfAjzxe0C2d68EhssJMC3xgHfsNYG6Z2-CG8UdvGQdElriz0FnDwTkQ-KAksowzmXOGS-ZBYNtr7LiVnT9AvvOMP2LRb7uXmk-nKK1urVlbtn2hwR2EYbqALNAhFdgEdp0yFmxoC1lI2JF1l3jb60dEVo3Ux-5BYzhZi2dm2yTDyRonJthlXRes977r_dThZBu4wEmyK_OEuW3i9tqzHaLXUntQOLnDSbLmPPHGKL5h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