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).