[Bug middle-end/124549] [13 regression] riscv64: false positive -Walloc-size-larger-than= with int multiplication

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Mar 17 17:54:49 GMT 2026


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124549

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So there is some jump threading happening which is causing
__perf_cpu_map__nr(orig) and __perf_cpu_map__nr(other) to be thought as less
than 0. And then converting a negative number from signed to unsigned it
becomes a big unsigned integer.

Adding:

 if (__perf_cpu_map__nr(orig) < 0)
   __builtin_unreachable();
 if (__perf_cpu_map__nr(other) < 0)
   __builtin_unreachable();

Right before  `tmp_len = __perf_cpu_map__nr(orig) + __perf_cpu_map__nr(other);`
fixes the warning.

I have not looked yet why there is jump threading happening in GCC 13 and not
14.


More information about the Gcc-bugs mailing list