<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/151113>151113</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Unnecessary instantiations of `constexpr` functions in `if constexpr (false)`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Eisenwave
</td>
</tr>
</table>
<pre>
```cpp
template <int N>
static constexpr void f() {
static_assert(N == 0);
}
void g() {
if constexpr (false) {
f<1>();
}
}
```
This fails to compile: https://gcc.godbolt.org/z/G87rsPjWo (GCC accepts)
Removing `constexpr` from `f()` makes this compile, but it shouldn't matter either way. `f()` is not odr-used, not constant-evaluated, or otherwise needs to be instantiated.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx0Ul1vozoQ_TXDyyiRMeEjDzykSdO36urqXt3HK2MGcNfYCA_pdn_9ypBqu602ioyYOXN8znBUCKZ3RDXkD5BfErXw4Of60QRyr-pGSePbtxoKsf31NIE4MY2TVUwI2dk4xmfIHkGcAis2GrV3gen7NOPNmxY7kBXII0L5AOKEiLjh_lch0Mwgq2eE7ALZBQXII2QRBuUlnuK0UvRfKEz34RqQVadsoN8h8ddBdk6juHV-o471O_12vnsDcfpnMAE7ZWxA9qj9OBlLkJ1wYJ4CZCeQV5DXXut979vGW977uQd5_QHy-lSVc_jr5T8fBT2dz6i0polDvHn18jeN_mZcj3GR7-qhENjNfozF-6piaVTfKCBHPe8y5BmbhdEwhsEvtnUgS8ZRMdOMZHigGV_V2_4TkwnoPKNv590SqI008X0VoBzv6Kbsonjr-Bl9JHo1gdARtesiGkKzoU0E7pO2ztpjdlQJ1WmZZ2UlRVokQ121bdHKkhp9KKujbLpKq4KqjESrVScOiamlkLko5VEcDyIt9nmqVVtUaVqJvCmkhIOgURm7t_Y2xuUmJoSF6jRP0zRLrGrIhjWsUmqrXA9SxtzOdRzYNUsf4CCsCRx-UbBhuyZ8m8gv-K9zpCkENb99sGa8C-i7r99ncXprGhebf0ofFCJZZlt_SovhYWn22o8gr1HT_bGbZv9CmkFeV48B5PVu81bLnwEAAP__bncawA">