Skip to content

fix: resolve compilation warnings - #47

Merged
jpnurmi merged 2 commits into
handlerfrom
jpnurmi/fix/warnings
Nov 20, 2026
Merged

jpnurmi merged 2 commits into
handlerfrom
jpnurmi/fix/warnings

Conversation

@jpnurmi

@jpnurmi jpnurmi commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

Fix the warnings that sentry-native reports when it builds breakpad with -Wall (getsentry/sentry-native#2315):

GCC 12+:

src/common/string_conversion.cc:107:16: error: array subscript 2 is outside array bounds of ‘wchar_t [1]’ [-Werror=array-bounds=]

macOS:

src/client/mac/handler/minidump_generator.cc:606:25: error: unused variable 'machine_state' [-Werror,-Wunused-variable]

MinGW:

src/client/windows/handler/exception_handler.h:63:9: error: unknown pragma ignored [-Werror,-Wunknown-pragmas]
src/client/windows/handler/exception_handler.h:65:9: error: unknown pragma ignored [-Werror,-Wunknown-pragmas]
src/client/windows/handler/exception_handler.h:523:9: error: unknown pragma ignored [-Werror,-Wunknown-pragmas]

`UTF32` is `unsigned long`, so reading the 4-byte `wchar_t` through
a `UTF32` pointer reads 8 bytes on 64-bit Linux and macOS:

    src/common/string_conversion.cc:107:16: error: array subscript 2 is outside array bounds of 'wchar_t [1]' [-Werror=array-bounds=]

Convert the character into a `UTF32` local instead.
- unknown `#pragma warning` in the Windows `exception_handler.h` with MinGW
- unused `machine_state` in `MinidumpGenerator::WriteContextARM64()` on macOS
@jpnurmi
jpnurmi merged commit 881d74b into handler Nov 20, 2026
9 checks passed
@jpnurmi
jpnurmi deleted the jpnurmi/fix/warnings branch November 20, 2026 12:45
jpnurmi added a commit to getsentry/sentry-native that referenced this pull request Nov 20, 2026
jpnurmi added a commit to getsentry/sentry-native that referenced this pull request Nov 23, 2026
#2315)

* build: apply `SENTRY_ERROR_ON_WARNINGS` to breakpad and crashpad

Build breakpad with `/W3` on MSVC and `-Wall` elsewhere, and treat
breakpad's and crashpad's warnings as errors with
`SENTRY_ERROR_ON_WARNINGS`.

Bump breakpad and crashpad to fix their warnings.

* build: respect `SENTRY_ERROR_ON_WARNINGS` on MSVC

Add `/WX` to sentry, crashpad and breakpad when the option is
enabled, like `-Werror` on other compilers.

* build: suppress the warnings new in clang-cl 21

clang-cl maps `-Wall` to `-Weverything`, so the warnings that clang 21
added fail the `sentry` build with the clang-cl 22.1.3 that ships with
Visual Studio 2026.

```text
include\sentry.h(955,11): error: identifier 'wchar_t' conflicts with a C++ keyword [-Werror,-Wc++-keyword]
src\sentry_attachment.c(233,12): error: not eliding copy on return [-Werror,-Wnrvo]
src\backends\sentry_backend_inproc.c(147,31): error: padding struct 'struct sentry_inproc_backend_config_s' with 3 bytes to align 'handler_strategy' [-Werror,-Wpadded]
```

* build: bump breakpad and crashpad to the merged warning fixes

Bump to the merge commits of getsentry/breakpad#47 and
getsentry/crashpad#181.

* build: copy the sentry warning options to sentry-crash on MSVC

`sentry-crash` copied the warning options from `sentry` only on GCC and
Clang, so `SENTRY_ERROR_ON_WARNINGS` did not reach the daemon on MSVC.

Ref: #2315 (comment)

* ci: add a ClangCL job for VS 2026

Run the ClangCL build and tests on `windows-2025-vs2026` as well, which
ships a newer clang-cl than VS 2022. Let CMake pick the installed Visual
Studio instead of forcing the VS 2022 generator.

* build: respect `SENTRY_ERROR_ON_WARNINGS` on clang-cl

clang-cl always built `sentry` with `-Werror`, so each new clang-cl
warning broke the build for everyone. Leave it to the `/WX` that
`SENTRY_ERROR_ON_WARNINGS` adds.
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