Compare commits

...

2 Commits

Author SHA1 Message Date
Carson Radtke 152d6eb989 bump version from 4.2.1 to 4.2.2 (#1244) 2026-05-20 16:31:39 -06:00
Carson Radtke d5097b0445 Patches for GSLv4.2.2 (#1243)
* export proper syntax for GSL_SUPPRESS for new VS (#1213)

A new Visual Studio version will soon be available that deprecates the
old syntax for gsl::suppress. Customers will now get a C4875 diagnostic
on suppressions that look like `gsl::suppress(x)` urging them to use
`gsl::suppress("x")` instead.

This change updates the `GSL_SUPPRESS` macro to preprocess
GSL_SUPPRESS(x) to gsl::suppress("x") on clang and new versions of MSVC.

* Revert unintended change to GSL_SUPPRESS (#1226)

PR #1213 changed this line. According to https://github.com/microsoft/GSL/pull/1213/files#r2586073058 the change was unintended. This PR reverts the change to the previous implementation.

Co-authored-by: Werner Henze <w.henze@avm.de>

---------

Co-authored-by: Werner Henze <34543625+beinhaerter@users.noreply.github.com>
Co-authored-by: Werner Henze <w.henze@avm.de>
2026-05-20 12:38:46 -06:00
5 changed files with 12 additions and 11 deletions
+2 -2
View File
@@ -28,8 +28,8 @@ jobs:
-DCMAKE_OSX_DEPLOYMENT_TARGET=9 \
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \
"-DMACOSX_BUNDLE_GUI_IDENTIFIER=GSL.\$(EXECUTABLE_NAME)" \
-DMACOSX_BUNDLE_BUNDLE_VERSION=4.2.1 \
-DMACOSX_BUNDLE_SHORT_VERSION_STRING=4.2.1 \
-DMACOSX_BUNDLE_BUNDLE_VERSION=4.2.2 \
-DMACOSX_BUNDLE_SHORT_VERSION_STRING=4.2.2 \
..
- name: Build
+1 -1
View File
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.14...3.16)
project(GSL VERSION 4.2.1 LANGUAGES CXX)
project(GSL VERSION 4.2.2 LANGUAGES CXX)
add_library(GSL INTERFACE)
add_library(Microsoft.GSL::GSL ALIAS GSL)
+2 -2
View File
@@ -49,7 +49,7 @@ dyn_array | &#x26
move_owner | &#x2610; | A helper function that moves one `owner` to the other
[final_action](docs/headers.md#user-content-H-util-final_action) | &#x2611; | A RAII style class that invokes a functor on its destruction
[finally](docs/headers.md#user-content-H-util-finally) | &#x2611; | A helper function instantiating [final_action](docs/headers.md#user-content-H-util-final_action)
[GSL_SUPPRESS](docs/headers.md#user-content-H-assert-gsl_suppress) | &#x2611; | A macro that takes an argument and turns it into `[[gsl::suppress(x)]]` or `[[gsl::suppress("x")]]`
[GSL_SUPPRESS](docs/headers.md#user-content-H-assert-gsl_suppress) | &#x2611; | A macro that takes an argument and turns it into `[[gsl::suppress(x)]]` or `[[gsl::suppress("x")]]` depending on the compiler.
[[implicit]] | &#x2610; | A "marker" to put on single-argument constructors to explicitly make them non-explicit
[index](docs/headers.md#user-content-H-util-index) | &#x2611; | A type to use for all container and array indexing (currently an alias for `std::ptrdiff_t`)
[narrow](docs/headers.md#user-content-H-narrow-narrow) | &#x2611; | A checked version of `narrow_cast`; it can throw [narrowing_error](docs/headers.md#user-content-H-narrow-narrowing_error)
@@ -202,7 +202,7 @@ include(FetchContent)
FetchContent_Declare(GSL
GIT_REPOSITORY "https://github.com/microsoft/GSL"
GIT_TAG "v4.2.1"
GIT_TAG "v4.2.2"
GIT_SHALLOW ON
)
+2 -2
View File
@@ -49,9 +49,9 @@ See [GSL.assert: Assertions](https://isocpp.github.io/CppCoreGuidelines/CppCoreG
This macro can be used to suppress a code analysis warning.
The core guidelines request tools that check for the rules to respect suppressing a rule by writing
`[[gsl::suppress(tag)]]` or `[[gsl::suppress(tag, justification: "message")]]`.
`[[gsl::suppress("tag")]]` or `[[gsl::suppress("tag", justification: "message")]]`.
Clang does not use exactly that syntax, but requires `tag` to be put in double quotes `[[gsl::suppress("tag")]]`.
Older versions of MSVC (VS 2022 and earlier) only understand `[[gsl::suppress(tag)]]` without the double quotes around `tag`.
For portable code you can use `GSL_SUPPRESS(tag)`.
+5 -4
View File
@@ -47,13 +47,14 @@
//
#if defined(__clang__)
#define GSL_SUPPRESS(x) [[gsl::suppress(#x)]]
#else
#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__NVCC__)
#elif defined(_MSC_VER) && _MSC_VER >= 1950
// Visual Studio versions after 2022 (_MSC_VER > 1944) support the justification message.
#define GSL_SUPPRESS(x) [[gsl::suppress(#x)]]
#elif defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__NVCC__)
#define GSL_SUPPRESS(x) [[gsl::suppress(x)]]
#else
#define GSL_SUPPRESS(x)
#endif // _MSC_VER
#endif // __clang__
#endif // defined(__clang__)
#if defined(__clang__) || defined(__GNUC__)
#define GSL_LIKELY(x) __builtin_expect(!!(x), 1)