https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88628
--- Comment #3 from merukun1125 at docomo dot ne.jp --- (In reply to Jakub Jelinek from comment #2) > clang++ agrees with g++ here. The lambda expression needs to be > instantiated so that it can be evaluated and expressions in discarded > statements are not instantiated. #include <type_traits> template<typename T> constexpr bool false_v = false; template<typename T> T get() { if constexpr (std::is_same_v<int, T>) return 0; else static_assert(false_v<T>, "..."); } int main() { get<int>(); } This code does not fail to compile. https://wandbox.org/permlink/jQB3P93GWTA2b4xs But #include <type_traits> template<typename T> T get() { if constexpr (std::is_same_v<int, T>) return 0; else static_assert(std::false_type{}, "..."); } int main() { get<int>(); } This code fail to compile. https://wandbox.org/permlink/MyyxwVGorihFGW2G So, I think that constexpr if is a function to suppress instantiation of templates of unselected branches. In other words, the first phase of two-phase name lookup is supposed to be executed. So, I thought that lambda expressions without dependency names should be evaluated.