Skip to content

Fix Windows CI: suppress MSVC C4875 from GSL on VS2026 toolset#191

Closed
bkaradzic-microsoft wants to merge 1 commit into
BabylonJS:mainfrom
bkaradzic-microsoft:fix/msvc-c4875-gsl
Closed

Fix Windows CI: suppress MSVC C4875 from GSL on VS2026 toolset#191
bkaradzic-microsoft wants to merge 1 commit into
BabylonJS:mainfrom
bkaradzic-microsoft:fix/msvc-c4875-gsl

Conversation

@bkaradzic-microsoft

Copy link
Copy Markdown
Contributor

Problem

Every Windows and UWP build is currently failing, e.g. in #190 and any new PR:

gsl\util(77,5): error C2220: the following warning is treated as an error
gsl\util(77,5): warning C4875: a non-string literal argument to [[gsl::suppress]]
                is deprecated and will be removed in a future release
[...AppRuntime.vcxproj] [...XMLHttpRequest.vcxproj] [...WebSocket.vcxproj] [...ScriptLoader.vcxproj]

This is not caused by any source change. The GitHub-hosted windows-2025 runner image was repointed to a VS2026 toolset (internal image name windows-2025-vs2026) between Jun 5 and Jun 9. Its newer MSVC introduces C4875 for the [[gsl::suppress]] attribute taking a non-string-literal argument — emitted from inside the GSL headers that we pull in transitively via arcana.cpp. Because our warnings_as_errors builds compile with /WX, the deprecation is promoted to a hard error and breaks every Windows/UWP target.

Evidence it's the image, not the code:

Run Date Image behind windows-2025
main last green Jun 5 windows-2025 (VS2025)
any PR now Jun 9+ windows-2025-vs2026 (VS2026)

The failing targets (arcana, AppRuntime, WebSocket, ScriptLoader, …) are unrelated to each other; the only common factor is GSL + /WX.

Fix

Suppress C4875 for MSVC at the top of the build. The warning is a deprecation inside a third-party header we don't control, so there's nothing to fix in our own code. This mirrors the existing /wd5205 (WinRT) suppression already present in warnings_as_errors in CMakeExtensions.

if(MSVC)
    add_compile_options(/wd4875)
endif()

Validation

  • Confirmed C4875 originates in gsl/util (via arcana), not our sources.
  • Verified /wd4875 is a valid, accepted MSVC option (no D9002).
  • CI on this branch is the authoritative check that Windows/UWP builds go green again on the VS2026 image.

The windows-2025 runner image was updated to a VS2026 toolset whose MSVC
emits C4875 (a non-string literal argument to [[gsl::suppress]] is
deprecated). This warning comes from the GSL headers pulled in transitively
via arcana.cpp, not from our code, and the /WX warnings_as_errors builds
promote it to an error, breaking every Windows/UWP build repo-wide.

Suppress C4875 for MSVC so third-party header deprecations don't fail our
builds, mirroring the existing /wd5205 (WinRT) suppression in CMakeExtensions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 9, 2026 14:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Suppresses a new MSVC warning (C4875) introduced by newer Visual Studio toolsets that is emitted from inside the GSL headers (transitively via arcana.cpp) and is currently breaking Windows/UWP builds due to /WX.

Changes:

  • Add an MSVC-only global compile option to disable warning C4875 (/wd4875).
  • Document why the suppression is needed (third-party header deprecation promoted to error under /WX).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bkaradzic-microsoft

Copy link
Copy Markdown
Contributor Author

Closed in favor of #192, which pins Windows CI to windows-2022 (VS2022). That keeps us on the known-good toolset and avoids C4875 entirely, so this /wd4875 suppression isn't needed.

bkaradzic-microsoft added a commit that referenced this pull request Jun 9, 2026
## Problem

Every Windows/UWP build is failing. GitHub repointed the
`windows-latest` label to a **VS2026** toolset (internal image
`windows-2025-vs2026`). Its newer MSVC emits **C4875** (`a non-string
literal argument to [[gsl::suppress]] is deprecated`) from inside the
GSL headers we pull transitively via `arcana.cpp`, and our `/WX` builds
promote it to a hard error.

## Fix

Pin the Win32 and UWP jobs to the **windows-2022** runner, which still
provides the established VS2022 toolset that doesn't emit C4875. This
restores green CI with no source or dependency-graph change, and matches
the approach taken in BabylonNative (BabylonJS/BabylonNative#1742).

(Originally proposed as a GSL v4.2.2 bump / `/wd4875` suppression — see
the closed #191 — but pinning the runner is the smaller, decoupled fix
and keeps us on the known-good toolchain.)

## Validation

CI on this branch confirms the Win32/UWP builds are green again on
windows-2022.

Co-authored-by: Branimir Karadžić <branimirk@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

2 participants