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

    <tr>
        <th>Summary</th>
        <td>
            Clang seemingly stuck in an infinite loop
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          nicola-gigante
      </td>
    </tr>
</table>

<pre>
    The attached file makes clang 17 take several minutes to compile, and I've never seen it terminate yet (on fast hardware), so I suspect an infinite loop is happening. I did not manage to reduce it because the "problem" is that it takes a lot of time, so `creduce` is not helpful here, unless setting a high timeout and waiting hours.

The culprit is around line 131447. 

```
131442 | map_t(class consumer *next, type_mapping_t ty_map, term_mapping_t te_map);
131443 |
131444 | template<typename ...Fs>
131445 | map_t(class consumer *next, Fs ...fs) : map_t(
131446 | next,
131447 |    ast::mapping(fs...), ast::mapping(fs...)
131448 | ) { }
```

The second constructor of this class should call the first but the two calls to `act::mapping` produce something that can also match the second constructor arguments and I think this causes an infinite loop. Indeed if I change that line as follows:

```
131447 | type_mapping_t(ast::mapping(fs...)), term_mapping_t(ast::mapping(fs...))
```

then the compilation goes smooth in a few seconds.

This is `clang --version`:
```
Homebrew clang version 17.0.6
Target: arm64-apple-darwin23.3.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin
```

The command line I use is:
```
clang++ -std=c++20 -fsyntax-only -x c++ report.cpp.txt
```

[report.cpp.txt](https://github.com/llvm/llvm-project/files/14822090/report.cpp.txt)

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