Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize "potentially uninitialized" pointers. #2654

Merged
merged 1 commit into from
Jun 7, 2021
Merged

Initialize "potentially uninitialized" pointers. #2654

merged 1 commit into from
Jun 7, 2021

Conversation

wolfpld
Copy link
Contributor

@wolfpld wolfpld commented May 14, 2021

In certain configurations MSVC may enable some sort of a static analyser during compilation, which marks "unsafe" code constructs. In this case the error messages are:

1>...\zstd\compress\zstd_lazy.c(1399): error C4703: potentially uninitialized local pointer variable 'dmsTagRow' used
1>...\zstd\compress\zstd_lazy.c(1407): error C4703: potentially uninitialized local pointer variable 'dmsRow' used

Initialization and usage of both dmsRow and dmsTagRow is contained within two separate if (dictMode == ZSTD_dictMatchState) sections. It is not possible to enter the second (usage) section without entering the first (initialization), but the analyser fails to see this.

This change silences the "error".

Copy link
Contributor

@felixhandte felixhandte left a comment

Choose a reason for hiding this comment

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

This is a reasonable fix for an unfortunate warning.

I worry that zealously fixing these false positives creates room for actually incorrect uses in the future. Initializing these values in this way allows for syntactically correct uses which are nonetheless semantically incorrect. But I don't think there's really anything we can do about that here.

@felixhandte felixhandte merged commit 8a3bdfa into facebook:dev Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants