Commit 2938571
Fix GCC may-be-uninitialized warning on
The DEF-removal pass had hoisted `niters = 100` from a compile-time
`DEF` (Cython-level literal) to a module-level `cdef int`. Cython emits
module-level `cdef int` as a `static int` global, and GCC declines to
constant-propagate through a mutable global — so `for k in range(niters)`
looked to the C compiler like it might execute zero iterations, and
`return k + 1` at the tail of `rescale_ruiz2001_c` / `rescale_scalgm_c`
looked like it might read an uninitialized `k`.
In practice `niters == 100` always (nothing ever writes to it), so the
warning is a false positive at runtime. It is still a real signal that
the as-written code permits the read, and the fix is free: restore
`niters` as a function-local `cdef int niters = 100` at the top of each
iterative scaler. Cython emits that as a stack local, GCC constant-
folds trivially, the warning vanishes, and the generated machine code
is identical to the DEF-era output.
`epsilon` stays at module level; it's a convergence tolerance, not a
loop bound, and does not appear in any uninit-read path.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>k in the iterative scalers1 parent eb92bef commit 2938571
1 file changed
Lines changed: 9 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
83 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
84 | 87 | | |
85 | | - | |
86 | 88 | | |
87 | 89 | | |
88 | 90 | | |
| |||
549 | 551 | | |
550 | 552 | | |
551 | 553 | | |
| 554 | + | |
| 555 | + | |
552 | 556 | | |
553 | 557 | | |
554 | 558 | | |
| |||
739 | 743 | | |
740 | 744 | | |
741 | 745 | | |
| 746 | + | |
| 747 | + | |
742 | 748 | | |
743 | 749 | | |
744 | 750 | | |
| |||
0 commit comments