[Bug c++/88628] lambda expression in static_assert in if constexpr is not evaluated
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Dec 28 12:40:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88628
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
lambda is AFAIK a local class, so you need to instantiate it. So it is more
similar to:
#include <type_traits>
template<typename T>
constexpr bool run() { return false; }
template<typename T>
T get() {
struct S {};
if constexpr (std::is_same_v<int, T>) return 0;
else static_assert(run <S> (), "Lambda expression is evaluated.");
}
int main() {
get<int>();
}
which also compiles fine (and doesn't compile if you use say int or something
non-dependent in run template-id).
More information about the Gcc-bugs
mailing list