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

    <tr>
        <th>Summary</th>
        <td>
            clang++ fills up memory until killed by system instead of giving compilation error
        </td>
    </tr>

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

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

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

<pre>
    Compiling the following code causes clang to take up all available system memory instead of giving a compilation error
```C++
// bug.cpp
#include <span>

template <std::size_t N>
auto bug(std::span<std::size_t, N> span) -> void
{
    std::make_index_sequence<N>();
}
auto main() -> int
{
    std::array<std::size_t, 10> arr;
 std::span<std::size_t, std::dynamic_extent> span{arr.data(), 2};
 bug(span);
}
```
ran with
```sh
$ clang++ bug.cpp -c -std=c++20 -emit-llvm -Xclang -disable-llvm-passes
```

**Expected behaviour**:
- Compilation error because the second template parameter of std::span is of type std::dynamic_extent and not std::size_t.

**Observed behaviour**:
- Clang takes up all available memory until it's killed by the system.

The bug appears on all clang versions, that support C++ 20 (std::mdspan):
Compiler explorer link:
- https://godbolt.org/z/WTjvv7z67
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVMFu4zgM_RrlQjhQ5CQeH3xo08lxdw4D7N4K2mJjTWTJK8mepl-_kOy4bTI7WMBIIFLi4yMfid6rkyGq2O6R7Z5WOITWuuqbMoq-rWorL9XBdr3SypwgtAQvVmv7M54aKwkaHDx5aDRGv4WAZ4KhB9QacESlsdYE_uIDddBRZ90FlPGBUIJ9gZMaYyiEJoFgUNYAOWcd40-MP7A9n74DE4_xm6ziyMQR6uG0bvr-asuVafQgCVh-8D0aln-dXek3UNdrDJM7SJY_sPzBqzd6DvDHcheHYGNgJr68X0rBbh8xcUjvILlFCVk8jFbJGbWYswUAWN52eKZnZSS9Pnv6ZyDTEMsPCV98YaJk-ZVj8fQhow6VmS5MMMqE36Ggc3j5dcobHt-jcwsS_A-ii0leDHaqeabXQCYs9ItHdG4tMeBMQxxARAoLyFzTqVb3LJdGT0eHBn6q0N44_dUgtpPkJlVclQBZA1lK9amZPIJDRp0KmdZjB9nfk04zqXzUZbJmPXpP_pdpXNHi9_W1pyaQhJpaHJUd3GSPdUnXMjjcihhqSgOSJsdTY42ERYc9OuwokIuD8KkHoHy0hUtP_1V5QCPB2AA3zVrfJ_5n7cmNv098Gl88k78f3nlqBxOUBhWYKDycldYx4mVilsb7E_T3lmJXAPue0HmwJkWd6j-S88oaH1USWgzgh763LsA85SA4fBzATi66mcNPlSYH9Npr68iBVub8gVEbQu_jOa2Kk5W11WFt3YmJ4xsTx7--_xjH4m1frGSVyzIvcUXVptjsxUaIjVi1Fd8VJBtectzwAsW23m5zXje7UvI9yVKsVCW42PKd4Js83-_EuiZeN6UsZZ1TzUXJtpw6VHodZRaxV8r7gapSFDu-0liT9mnvCjGLWcQV7Koky3o4ebblWvng3yMEFTRVH7X_orROXfvUp_cGzbv3funerdzV4HR1UzgV2qFeN7Zj4hiTmP-y3tkf1AQmjomTZ-KYaP0bAAD__4kb8Hg">