Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch2 v3 and Visual C++ 2015 Update 3 #2624

Closed
trueqbit opened this issue Jan 16, 2023 · 1 comment
Closed

Catch2 v3 and Visual C++ 2015 Update 3 #2624

trueqbit opened this issue Jan 16, 2023 · 1 comment

Comments

@trueqbit
Copy link

Visual C++ Update 3 reports itself as being capable of C++14 but is still lacking

  • Extended constexpr
  • Aggregates with default member initializers

It would be great to keep VC++ 2015 Update 3 for a while longer, as long as Microsoft still supports it (extended support until the end of 2025) and/or vcpkg lists it as a minimum requirement.

It is usually not difficult to keep a few things in mind, and it is good practice to test certain C++ functions, which you do anyway.

A concrete use case is sqlite_orm (v1.8), which still runs appveyor unit tests using Visual C++ 2015 Update 3 as the minimal C++14 base compiler.

When updating the test dependency of sqlite_orm to Catch2 v3, I encountered the following compile error:

catch2/internal/catch_stringref.hpp(58): error C3249: illegal statement or sub-expression for 'constexpr' function
catch2/internal/catch_stringref.hpp(76): error C3249: illegal statement or sub-expression for 'constexpr' function

This is because pre-C++14 contexpr function's body can only be a single return statement. Everything else gets rejected, specifically:

constexpr auto StringRef::operator[] ( size_type index ) const noexcept -> char {
    assert(index < m_size);
    return m_start[index];
}

constexpr StringRef StringRef::substr(size_type start, size_type length) const noexcept {
    if (start < m_size) {
        const auto shortened_size = m_size - start;
        return StringRef(m_start + start, (shortened_size < length) ? shortened_size : length);
    } else {
        return StringRef();
    }
}
@horenmar
Copy link
Member

Sorry, but I am not interested in keeping VS 2015 compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants