From 618e4cd90b5778d02ad613ee8786427c1344c0d9 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Wed, 8 Jan 2025 18:22:27 -0500 Subject: [PATCH] Help gcc-11.4 --- pandas/_libs/hashtable_func_helper.pxi.in | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pandas/_libs/hashtable_func_helper.pxi.in b/pandas/_libs/hashtable_func_helper.pxi.in index fdb77a56541de..9744b7f67502f 100644 --- a/pandas/_libs/hashtable_func_helper.pxi.in +++ b/pandas/_libs/hashtable_func_helper.pxi.in @@ -114,7 +114,15 @@ cdef value_count_{{dtype}}(const {{dtype}}_t[:] values, bint dropna, const uint8 result_counts[i] = table.vals[k] if na_counter > 0: - assert n > 0 # val will be uninitialized without this + # gcc-11.4 on ubuntu 22.04 cannot see that val won't be unassigned + # when we make it into this branch + assert n > 0 + {{if dtype == 'object'}} + val = values[n - 1] + {{else}} + val = {{to_c_type}}(values[n - 1]) + {{endif}} + result_counts[table.size] = na_counter result_keys.append(val)