https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88628

            Bug ID: 88628
           Summary: lambda expression in static_assert in if constexpr is
                    not evaluated
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: merukun1125 at docomo dot ne.jp
  Target Milestone: ---

The following code should fail to compile.

#include <type_traits>

template<typename T>
T get() {
    if constexpr (std::is_same_v<int, T>) return 0;
    else static_assert([]{return false;}(), "Lambda expression is evaluated.");
}

int main() {
    get<int>();
}

wandbox
https://wandbox.org/permlink/9FWcmSTY6uPEF09r

Reply via email to