2 years ago

#46154

test-img

Diederick C. Niehorster

static_assert doesn't fire on MSVC

The below example code fires the "testing" assert with gcc and clang, but not MSVC. Only when the line marked comment this out is commented out does it fire. With GCC and clang it fires both with and without that line. Is that expected?

#include <type_traits>

template <bool B>
constexpr void issue_error()
{
    static_assert(B, "testing");
};

int main()
{
    issue_error<false>();
    static_assert(std::is_same_v<int,char>,"!!"); // comment this out
}

c++

compile-time

static-assert

0 Answers

Your Answer

Accepted video resources