Skip to contentSkip to conversation

bunzip: work around gcc13 warning

PATCH In review Jan Beulich 2 participants 2 messages Mar 13, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 bunzip: work around gcc13 warning

While provable that length[0] is always initialized (because symCount cannot be zero), upcoming gcc13 fails to recognize this and warns about the unconditional use of the value immediately following the loop.

See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106511.

---
v2: Put new code on a separate line and add comment.
---
RFC: We've cloned this code from Linux and the code is unchanged there.
Therefore the same issue should exist there, and we may better get whatever workaround is going to be applied there. But I'm unaware of the issue, so far, having been observed in and reported against Linux. This may be because they disable the maybe-uninitialized warning by default, and they re-enable it only when building with W=2.

xen/common/bunzip2.c +5 -0
@@ -233,6 +233,11 @@ static int __init get_next_block(struct
 		   becomes negative, so an unsigned inequality catches
 		   it.) */
 		t = get_bits(bd, 5)-1;
+		/* GCC 13 has apparently improved use-before-set detection, but
+		   it can't figure out that length[0] is always intialized by
+		   virtue of symCount always being positive when making it here.
+		   See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106511. */
+		length[0] = 0;
 		for (i = 0; i < symCount; i++) {
 			for (;;) {
 				if (((unsigned)t) > (MAX_HUFCODE_BITS-1))
Acked-by on v2 1/1
#1 lore raw
Quoted 8 lines · Jan Beulich

While provable that length[0] is always initialized (because symCount cannot be zero), upcoming gcc13 fails to recognize this and warns about the unconditional use of the value immediately following the loop.

See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106511.