Potentially uninitialized local variable used `partition`
Closed this issue · 4 comments
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. 😅
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 ?
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 :)
Should be resolved by 026acf9.
Please let me know if that fixed your warning and I'll close this issue.
Thanks!
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.