<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/68098>68098</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
windows clang 17.0.1: broken template argument deduction in a constructor within a `throw` expression
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
egor-bychin-sd
</td>
</tr>
</table>
<pre>
Consider this piece of code:
```C++
class A
{
public:
A(auto &&...args) { static_assert(sizeof...(args) == 0); }
};
int main() {
throw A{};
}
```
It should be compiled correctly, but on Windows I get the following error:
```
PS C:\dev> clang++ -std=c++20 .\cpp.cpp
.\cpp.cpp:4:39: error: static assertion failed due to requirement 'sizeof...(args) == 0'
4 | A(auto &&...args) { static_assert(sizeof...(args) == 0); }
| ^~~~~~~~~~~~~~~~~~~~
.\cpp.cpp:8:11: note: in instantiation of function template specialization 'A::A<A &>' requested here
8 | throw A{};
| ^
.\cpp.cpp:4:55: note: expression evaluates to '1 == 0'
4 | A(auto &&...args) { static_assert(sizeof...(args) == 0); }
| ~~~~~~~~~~~~~~~~^~~~
1 error generated.
```
This problem only happens when an instance of `A` is used in a `throw` expression.
However, on godbolt there are [no any issues](https://godbolt.org/z/dfz95dK7e), so I guess it must be something platform dependent.
Here's the version that I use:
```
PS C:\dev> clang++ --version
clang version 17.0.1
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVU2PqzYU_TXO5ioI7PC1yIJJJupTX6UntWqXTwbfgFtjU9skb2bR317ZkEn6vhaVKhWhmWCu78c5xwfunOw14p7kTyQ_bvjsB2P32Bu7bV-6QeqtE5vWiJf9wWgnBVrwg3QwSewQzBk6I5CwhqRHkjakSJf7QOhTuONqp7hzcAsp19VpbpXs3rYCADSEVnz2BggtCC2SJOG2d4TWQMonc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