The following code:
#include <type_traits>
struct X {
static constexpr void x() {}
};
template <class T1, class T2>
constexpr bool makeFalse() { return false; }
template <class T>
void foo() {
T tmp;
auto f = [](auto type) {
if constexpr (makeFalse<T, decltype(type)>()) {
T::x(); // <- clang does not discard
} else {
// noop
}
};
}
int main() {
foo<int>();
}
does not compile with Clang, but compiles with GCC. I can't see anything wrong with this code, but I'm not sure. Is Clang right not compiling it?