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

Potentially uninitialized local variable used partition #10

Closed
Gocnak opened this issue Sep 14, 2022 · 4 comments
Closed

Potentially uninitialized local variable used partition #10

Gocnak opened this issue Sep 14, 2022 · 4 comments

Comments

@Gocnak
Copy link

Gocnak commented Sep 14, 2022

Hello! Your library is excellent and I wanted to report this warning we got from integrating bcdec into our engine.

Warning C4701 potentially uninitialized local variable 'partition'
https://github.com/iOrange/bcdec/blob/main/bcdec.h#L870

It seems like there's a very rare case that could happen where partition is uninitialized. I noticed the if-else block above on L829 sets it to 0 but only in the if, not the else. I'm not too knowledgeable on BC formats so I wouldn't know what the proper value to set it here would be, hence me reporting this warning we get in an issue rather than submitting a PR. 😅

@iOrange
Copy link
Owner

iOrange commented Sep 15, 2022

Hi!

All modes < 10 get their partition from the bitstream, and every mode >= 10 is using partition 0.
My guess is that your compiler get's confused. Could you please specify your compiler so that I could try to repro this warning ?

@iOrange
Copy link
Owner

iOrange commented Sep 15, 2022

Actually, to play it safe I can just init partition to 0 at start and then read it from bitstream for modes that require it. This should make any compiler happy :)

@iOrange
Copy link
Owner

iOrange commented Sep 15, 2022

Should be resolved by 026acf9.
Please let me know if that fixed your warning and I'll close this issue.
Thanks!

@Gocnak
Copy link
Author

Gocnak commented Sep 15, 2022

Perfect, this fixes it nicely! Thank you so much.

We use the latest MSVC (C++23) to compile this library as part of our engine for Windows, and clang v14 for Linux, for future reference.

@iOrange iOrange closed this as completed Sep 15, 2022
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

No branches or pull requests

2 participants