<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/57254>57254</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Platform-dependent constexpr
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Sainan
</td>
</tr>
</table>
<pre>
```C++
#include <iostream>
struct Usertype
{
[[nodiscard]] static constexpr bool getSomething() noexcept
{
return true;
}
};
void checkSomething(Usertype& ud)
{
if constexpr (ud.getSomething()) // only linux, only works if ud is not a reference or r-value
//if constexpr (std::remove_reference_t<decltype(ud)>::getSomething()) // always works
{
std::cout << "Alright!\n";
}
}
int main()
{
Usertype ud;
checkSomething(ud);
}
```
This compiles fine on Windows, but on Linux I get "constexpr if condition is not a constant expression".
Tested against clang versions:
- Windows: 14.0.5, 13.0.0
- Linux: 14.0.0, 13.0.1, 13.0.0, 10.0.0-4ubuntu1, 7.0.1-8+deb10u2
Using C++17 in all instances.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx9VE1v2zAM_TXyRYhhy7GdHHxImxUYsMOArtixkCXG0apIgT7S5t-PchLPa7cKhC2JNPkeH-HeynNHmuJi94TdJSu2pNgQVikjdJRASXWvrA8O-IFUX67u8YmXUQT65MGF8xGurvaaguIi9R2asVJ5wZ0k9RaN-sCDElRY4wO8HR3trdV0gPBoDxD2ygyErQhbU2PhTcAxzBLOs6flIERnKCIBUs0rt9sbnu3kuDxPVkkq9iBe5vUmFqyhUWL1f9BRuxlo_CbK_CPqBJywBzRqjT5TrUx8I-z-cnq17sWnRFFS5ZFhoBxJ7MCBEUCto25x4jrCjMqY7H1tHySpNmgODvYEz1OO54CKSRD6wmZ1IYPKjdGf4uX6lZ_9BeMnPZ9KCxtDmg80TME22qlhHwgrSX1v8OL_iszkUCbQA1fmiuZj12_KJFnmCT9IeGV6977MbcLnVX_ssfvCHo5Kg6c7ZbD3hv5URtpXn9TqkRrefEvq0a9pOhPFPxJc9JAqKIyalBz9HBmlGPAenfhV_ldlwAyS8gE5-0CF5magJ3Ap1qe-jlGLCUu1oeUyL_I6oSor3BW3kBHcFFBMAeUsNO2KtFssYx9NiKOzTVELbPidhL4sIpsjfPLYT3r9H5QtVQYnQ1M1UhPg8wy6smmKdbWui2Umu0rilmdBBQ3dd83DzrrDQsIRjARsxtS1LDrd7UM4jkTHoRtU2Mc-RynwoPXp9locnf0FIqTR9z4CivJQt6xeZvuuZ3XZl7u2WC17sWoYADQNtFUFqwrqZZNp3oP23fj72WaqYwVjxapcs6JAxHnZNqKFVgrJa1btVmRZAI6gzlPh3Lohc92IoY-DR6dWPvg_To66Dgbglp_HsLeue0RBuclGtN0I9Tc8apMx">