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

    <tr>
        <th>Summary</th>
        <td>
            `std::make_index_sequence` is perhaps mangled incorrectly in return type of template functions
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            libc++,
            clang:frontend,
            ABI
      </td>
    </tr>

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

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

<pre>
    According to the standard, `std::make_index_sequence` should be an alias to `std::integer_sequence`. Inside clang we use a special builtin, `__make_index_seq`, to implement `std::make_index_sequence` more efficiently.

Consider
```C++
#include <utility>

template<int N>
std::make_index_sequence<N> f() {};
template std::make_index_sequence<1> f<1>();

template<int N>
void g(std::make_index_sequence<N>) {};
template void g<1>(std::make_index_sequence<1>);

void h(std::make_index_sequence<1>) {};
```

The instantiation of `f` contains `__make_index_seq` in the mangled type of the return value under both libstdc++ and libc++:

```
__make_integer_seq<std::__1::integer_sequence, unsigned long, 1> f<1>()
_Z1fILi1EE18__make_integer_seqINSt3__116integer_sequenceEmXT_EEv

void g<1>(std::__1::integer_sequence<unsigned long, 0ul>)
_Z1gILi1EEvNSt3__116integer_sequenceImJLm0EEEE

h(std::__1::integer_sequence<unsigned long, 0ul>)
_Z1hNSt3__116integer_sequenceImJLm0EEEE
```

GCC mangles `f` as `_Z1fILi1EESt16integer_sequenceImJXspcl14__integer_packT_EEEEv`. This is at least inconsistent w.r.t to GCC and perhaps violates the standard (since `std::make_index_sequence` should just be an alias).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytlU1z2jAQhn-NuWjqsWXHwMGHhJAOnU4uyaHTCyNLsq1Ellx90PLvu7LBISRp6UwZDSCtd_eR9O660mxfXlOqDROqQU4j13JkHVGMGBbhFYqKxDoWZdcwOvLMt0Ix_mtr-Q_PFeVgRrbVXjJUcUQU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