[mpich-discuss] MPICH 5.0.0 released: a warning
Jenke, Joachim
jenke at itc.rwth-aachen.de
Thu Feb 5 13:24:52 CST 2026
Hi Hui,
I think the proper way to fix the issue is to use size_t for length variables in the first place ;)
Regarding your typecasting concern: If I remember correctly, it is implementation-specific behavior, whether widening or unsigned conversion happens first (resulting in 0 or 1 in all additional bits, if the value was negative). Depending on the compiler, your typecast might be the thing that actually happens. If your goal is to always pass an insanely large value for negative values, you should force the widening to happen on signed: (size_t)(long long)upid_len
-Joachim
Am 05.02.2026 18:06 schrieb "Zhou, Hui via discuss" <discuss at mpich.org>:
It can be ignored.
I am curious how the compiler arrive at that warning. 18446744071562067968 and 18446744073709551615 in hex are
0xFFFFFFFF80000000 and 0xFFFFFFFFFFFFFFFF, if we cast to unsigned int, they are 2147483648 - 4294967295, and
if we cast to signed int, they are -2147483648 - -1. So The compiler looked at the type of upid_len, which is an int, and
decided it could have negative values, which will become in the range of 0xFFFFFFFF80000000 and
0xFFFFFFFFFFFFFFFF and that exceeds maximum object size.
So they are complaining an implicit cast from int to size_t in memcpy. And they want us to add an explicit
`(unsigned) upid_len` cast, which does nothing in improving the code safety. In fact, it makes the code worse. Before, if we
accidentally had negative values in int, which is quite common in errors, the negative value will trigger an immediate error
in memcpy. With the cast to (unsigned), the negative values suddenly become good value for memcpy and it will happily
corrupt the memory! It is a warning designed to be silenced and force people to write bad code.
How stupid is that?
--
Hui
________________________________
From: jdelia--- via discuss <discuss at mpich.org>
Sent: Wednesday, February 4, 2026 5:37 PM
To: MPICH DISCUSS at MPICH.ORG <discuss at mpich.org>
Cc: jdelia at intec.unl.edu.ar <jdelia at intec.unl.edu.ar>
Subject: [mpich-discuss] MPICH 5.0.0 released: a warning
Hi there, Today I downloaded the [mpich-announce] MPICH 5. 0. 0 released on a x86_64-pc-linux-gnu Linux machine with Fedora 43. Although the building is fine, the following warning appears during compilation: .. /src/mpid/ch4/src/ch4_proc. c: In
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
ZjQcmQRYFpfptBannerEnd
Hi there,
Today I downloaded the [mpich-announce] MPICH 5.0.0 released
on a x86_64-pc-linux-gnu Linux machine with Fedora 43.
Although the building is fine, the following warning appears during compilation:
../src/mpid/ch4/src/ch4_proc.c: In function ‘MPIDIU_upidhash_add’:
../src/mpid/ch4/src/ch4_proc.c:336:5: warning: ‘memcpy’ specified bound between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
336 | memcpy(t->upid, upid, upid_len);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I'd like to know if it can be ignored, or if it would be better to fix it (and
how to do so). Thanks,
Regards.
Jorge D'Elia.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mpich.org/pipermail/discuss/attachments/20260205/c60b9514/attachment-0001.html>
More information about the discuss
mailing list