diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..be72e49 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,29 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: 'Status: Open, Type: Bug' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +```c++ +#include + +// your repro here: ... +``` + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Spec (please complete the following information):** + - OS: [e.g. Windows] + - Compiler: [e.g. MSVC] + - C++ Version: [e.g. C++20] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index a2c88fc..97259a8 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -38,7 +38,7 @@ jobs: echo "Emulator starting in background" - name: Configure - run: cmake -Werror=dev -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_LATEST_HOME/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=16 -DANDROID_ABI=x86_64 -DCMAKE_BUILD_TYPE=Debug .. + run: cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_LATEST_HOME/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=16 -DANDROID_ABI=x86_64 -DCMAKE_BUILD_TYPE=Debug .. - name: Build run: cmake --build . --parallel diff --git a/.github/workflows/compilers.yml b/.github/workflows/compilers.yml index 23866a6..14daeb6 100644 --- a/.github/workflows/compilers.yml +++ b/.github/workflows/compilers.yml @@ -23,6 +23,13 @@ jobs: exclude: - gcc_version: 10 cxx_version: 23 + # https://github.com/google/googletest/issues/4232 + # Looks like GoogleTest is not interested in making version 1.14 + # work with gcc-12. + - gcc_version: 12 + cxx_version: 20 + - gcc_version: 12 + cxx_version: 23 runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -54,7 +61,7 @@ jobs: xcode: strategy: matrix: - xcode_version: [ '14.3.1', '15.4' ] + xcode_version: [ '15.4' ] build_type: [ Debug, Release ] cxx_version: [ 14, 17, 20, 23 ] runs-on: macos-latest diff --git a/CMakeLists.txt b/CMakeLists.txt index 71bb997..b1d24e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.14...3.16) -project(GSL VERSION 4.0.0 LANGUAGES CXX) +project(GSL VERSION 4.1.0 LANGUAGES CXX) add_library(GSL INTERFACE) add_library(Microsoft.GSL::GSL ALIAS GSL) diff --git a/README.md b/README.md index 0e266b4..f1278da 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # GSL: Guidelines Support Library -[![Build Status](https://dev.azure.com/cppstat/GSL/_apis/build/status/microsoft.GSL?branchName=main)](https://dev.azure.com/cppstat/GSL/_build/latest?definitionId=1&branchName=main) +[![CI](https://github.com/Microsoft/GSL/actions/workflows/compilers.yml/badge.svg)](https://github.com/microsoft/GSL/actions/workflows/compilers.yml?query=branch%3Amain) +[![vcpkg](https://img.shields.io/vcpkg/v/ms-gsl)](https://vcpkg.io/en/package/ms-gsl) The Guidelines Support Library (GSL) contains functions and types that are suggested for use by the [C++ Core Guidelines](https://github.com/isocpp/CppCoreGuidelines) maintained by the [Standard C++ Foundation](https://isocpp.org). @@ -106,8 +107,8 @@ If you successfully port GSL to another platform, we would love to hear from you Target | CI/CD Status :------- | -----------: -iOS | ![CI_iOS](https://github.com/microsoft/GSL/workflows/CI_iOS/badge.svg) -Android | ![CI_Android](https://github.com/microsoft/GSL/workflows/CI_Android/badge.svg) +iOS | [![CI_iOS](https://github.com/microsoft/GSL/workflows/CI_iOS/badge.svg?branch=main)](https://github.com/microsoft/GSL/actions/workflows/ios.yml?query=branch%3Amain) +Android | [![CI_Android](https://github.com/microsoft/GSL/workflows/CI_Android/badge.svg?branch=main)](https://github.com/microsoft/GSL/actions/workflows/android.yml?query=branch%3Amain) Note: These CI/CD steps are run with each pull request, however failures in them are non-blocking. @@ -197,7 +198,7 @@ include(FetchContent) FetchContent_Declare(GSL GIT_REPOSITORY "https://github.com/microsoft/GSL" - GIT_TAG "v4.0.0" + GIT_TAG "v4.1.0" GIT_SHALLOW ON ) diff --git a/include/gsl/pointers b/include/gsl/pointers index 7ed0789..cd07939 100644 --- a/include/gsl/pointers +++ b/include/gsl/pointers @@ -75,7 +75,7 @@ using std::unique_ptr; // T must be a pointer type // - disallow construction from any type other than pointer type // -template ::value>> +template ::value, bool> = true> using owner = T; // @@ -117,7 +117,7 @@ public: not_null(const not_null& other) = default; not_null& operator=(const not_null& other) = default; constexpr details::value_or_reference_return_t get() const - noexcept(noexcept(details::value_or_reference_return_t{std::declval()})) + noexcept(noexcept(details::value_or_reference_return_t(std::declval()))) { return ptr_; } diff --git a/include/gsl/span b/include/gsl/span index d2ef9f7..a01b687 100644 --- a/include/gsl/span +++ b/include/gsl/span @@ -140,7 +140,9 @@ namespace details constexpr span_iterator(pointer begin, pointer end, pointer current) : begin_(begin), end_(end), current_(current) - {} + { + Expects(begin_ <= current_ && current <= end_); + } constexpr operator span_iterator() const noexcept { @@ -149,21 +151,18 @@ namespace details constexpr reference operator*() const noexcept { - Expects(begin_ && end_); - Expects(begin_ <= current_ && current_ < end_); + Expects(current_ != end_); return *current_; } constexpr pointer operator->() const noexcept { - Expects(begin_ && end_); - Expects(begin_ <= current_ && current_ < end_); + Expects(current_ != end_); return current_; } constexpr span_iterator& operator++() noexcept { - Expects(begin_ && current_ && end_); - Expects(current_ < end_); + Expects(current_ != end_); // clang-format off GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute // clang-format on @@ -180,8 +179,7 @@ namespace details constexpr span_iterator& operator--() noexcept { - Expects(begin_ && end_); - Expects(begin_ < current_); + Expects(begin_ != current_); --current_; return *this; } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 065a317..1f2bf7a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -110,6 +110,7 @@ if(MSVC) # MSVC or simulating MSVC -Wno-shift-sign-overflow # GTest gtest-port.h -Wno-undef # GTest -Wno-used-but-marked-unused # GTest EXPECT_DEATH + -Wno-switch-default # GTest EXPECT_DEATH $<$: # no support for [[maybe_unused]] -Wno-unused-member-function -Wno-unused-variable diff --git a/tests/CMakeLists.txt.in b/tests/CMakeLists.txt.in index 2535f8f..4f919f6 100644 --- a/tests/CMakeLists.txt.in +++ b/tests/CMakeLists.txt.in @@ -1,10 +1,10 @@ -cmake_minimum_required(VERSION 3.0.2) +cmake_minimum_required(VERSION 3.13) project(googletest-download NONE) include(ExternalProject) ExternalProject_Add(googletest GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG 1b18723e874b256c1e39378c6774a90701d70f7a + GIT_TAG v1.14.0 SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-src" BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-build" CONFIGURE_COMMAND ""