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

    <tr>
        <th>Summary</th>
        <td>
            [clang] Ambiguity between function declaration and definition when using pack indexing
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          FSK-idk
      </td>
    </tr>
</table>

<pre>
    Godbolt: https://godbolt.org/z/817Kve9zc

It seems that clang can't compile code if I decide to separate the declaration and implementation of a function with pack indexing in some cases. However, if you comment out the declaration, it will compile.

```cpp
#include <concepts>
#include <iostream>


// in requires expression

template <class... Types>
requires std::same_as<Types...[0], int>
void print(double d);

template <class... Types>
requires std::same_as<Types...[0], int>
void print(double d) {
 std::cout << "it doesn't work " << static_cast<Types...[0]>(d) << "\n";
}


// in return type

template <class... Types>
Types...[0] convert(double d);

template <class... Types>
Types...[0] convert(double d) {
    return static_cast<Types...[0]>(d);
}


int main() {
 print<int, int>(12.34);
    std::cout << "convert: " << convert<int, int>(12.34) << "\n";

    return 0;
}
```

Output
```
<source>:30:5: error: call to 'print' is ambiguous
   30 |     print<int, int>(12.34);
      | ^~~~~~~~~~~~~~~
<source>:9:6: note: candidate function [with Types = <int, int>]
    9 | void print(double d);
      |      ^
<source>:13:6: note: candidate function [with Types = <int, int>]
   13 | void print(double d) {
      |      ^
<source>:31:33: error: call to 'convert' is ambiguous
 31 |     std::cout << "convert: " << convert<int, int>(12.34) << "\n";
 |                                 ^~~~~~~~~~~~~~~~~
<source>:21:13: note: candidate function [with Types = <int, int>]
   21 | Types...[0] convert(double d);
      |             ^
<source>:24:13: note: candidate function [with Types = <int, int>]
   24 | Types...[0] convert(double d) {
 |             ^
2 errors generated.
Compiler returned: 1
```


</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzEVktv4zYQ_jXUZRBBIi0_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