On the CPU, reducing a row of 8,421,505 unsigned bytes set to 255 into CV_64F returns -2,147,483,521. The integer accumulator overflows before the result is stored. The correct sum is 2,147,483,775.
This patch uses a double accumulator for signed and unsigned 8-bit input with CV_64F output. For CV_32F, it keeps the existing fast path for lengths that are safe to sum in an int and uses double for longer reductions.
The regression test covers positive overflow and negative underflow on both axes and with both floating-point outputs. All 48 selected CPU reduction tests passed on Windows with MSVC. A separate strided, three-channel check failed before the fix and passed afterward.
The unsigned SUM case overlaps with #31079. This draft also exercises the signed 8-bit paths on 5.x. The 4.x PR covers additional SUM2 and default-output AVG cases. This draft can be reassessed when that change is ported.