Skip to content

fix: initialize local variable to prevent c4701 warning on windows arm#1122

Merged
supervacuus merged 2 commits into
getsentry:masterfrom
josh-kosberg:patch-1
Jan 23, 2025
Merged

fix: initialize local variable to prevent c4701 warning on windows arm#1122
supervacuus merged 2 commits into
getsentry:masterfrom
josh-kosberg:patch-1

Conversation

@josh-kosberg

@josh-kosberg josh-kosberg commented Jan 21, 2025

Copy link
Copy Markdown
Contributor

When trying to build the sentry toolchain on windows arm, I am seeing the following warning:

1>------ Build started: Project: sentry, Configuration: Debug ARM64 ------
1>sentry_core.c
sentry-native\src\sentry_core.c(404,1): error C2220: the following warning is treated as an error
sentry-native\src\sentry_core.c(404,1): warning C4701: potentially uninitialized local variable 'event_id' used
1>Done building project "sentry.vcxproj" -- FAILED.

When we compile the sentry code, we enable warnings as errors globally and hit this warning which fails our builds unless we disable it. It looks like a simple fix. It appears on arm, a separate optimization path is hit and spits out this warning, but it doesn't create the same warning in an x86_64 build. Would like to just get this updated as I think it is also more "correct" this way as well!

#skip-changelog

@markushi
markushi requested a review from supervacuus January 21, 2025 19:31
@codecov

codecov Bot commented Jan 22, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.64%. Comparing base (56198fc) to head (7c4bc6c).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1122      +/-   ##
==========================================
- Coverage   82.68%   82.64%   -0.04%     
==========================================
  Files          53       53              
  Lines        7930     7930              
  Branches     1240     1240              
==========================================
- Hits         6557     6554       -3     
- Misses       1263     1264       +1     
- Partials      110      112       +2     

@kahest
kahest requested a review from JoshuaMoelans January 22, 2025 08:39

@supervacuus supervacuus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is a false positive since we only write to the event_id. I am okay with initializing it; if the value is already initialized, it will behave the same since it is a pure output parameter.

@JoshuaMoelans JoshuaMoelans left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@JoshuaMoelans JoshuaMoelans changed the title Prevent c4701 warning on windows arm fix: initialize local variable to prevent c4701 warning on windows arm Jan 22, 2025
@supervacuus
supervacuus merged commit 57c38d9 into getsentry:master Jan 23, 2025
@supervacuus

supervacuus commented Feb 25, 2025

Copy link
Copy Markdown
Collaborator

@jkosberg, I have bad news: #1138 accidentally removed that initialization in its first commit (probably from an old branch) and this was never rectified and thus got released with 0.8.0.

If you can wait, I recommend not upgrading to 0.8.0; I will release 0.8.2 with that initialization because clang-cl (support for which I will release with 0.8.2) also complains about the missing init.

BernhardMarconato pushed a commit to elgatosf/sentry-native that referenced this pull request Apr 21, 2026
getsentry#1122)

* Prevent c4701 warning on windows arm

* comment that init has no semantic meaning

---------

Co-authored-by: Mischan Toosarani-Hausberger <[email protected]>
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.

3 participants