Fix regression in wide-int copy for zero-length integers.
Restores correct --enable-checking=rtl builds by fixing a bug in wide-int copy.
A regression in the wi::copy function for GCC’s wide-integer type caused a “maybe used uninitialized” error during bootstrap when the integer length was zero. This change ensures that the function checks for a non-zero length before attempting to copy, resolving the build issue. The problem was exposed by a change in thread backedges that revealed an uninitialized pointer path.
In Details
The wi::copy function in GCC's wide-int.h has an invariant: len > 0 implies val is defined. If len == 0, val can be uninitialized. The copy operation did not guard against len == 0, leading to a potential use-after-uninitialized error. This fix adds a len != 0 check. The issue is subtle and arises from specific inlining and loop peeling optimizations.
- wide-int
- GCC's internal representation for arbitrary-precision integers, used for values exceeding standard machine integer types.
- bootstrap
- The process of compiling a compiler using an earlier version of itself. This is a common way to build compilers for new architectures or to detect regressions.
- thread backedges
- In GCC's internal representation, this likely refers to optimizations or analyses related to control flow graphs, possibly involving loop optimizations or thread-local storage.