https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102259
--- Comment #15 from Michel Morin <mimomorin at gmail dot com> --- FreeBSD's `read` manpage has been updated recently: https://github.com/freebsd/freebsd-src/commit/3e95158 [2024-02-10] read.2: Describe debug.iosize_max_clamp … read() … will succeed unless: - The value nbytes is greater than INT_MAX. + The value nbytes is greater than SSIZE_MAX + (or greater than INT_MAX, if the sysctl debug.iosize_max_clamp is non-zero). Then, I checked the source code to find the related changes. It turns out that the manual hadn't been updated to reflect the code changes over ten years. The configuration `iosize_max_clamp` (default to 1) was added in FreeBSD ver. 10: https://github.com/freebsd/freebsd-src/commit/526d0bd [2012-02-21] Fix found places where uio_resid is truncated to int. The default was changed to 0 in FreeBSD ver. 11: https://github.com/freebsd/freebsd-src/commit/cd4dd44 [2013-10-15] By default, allow up to SSIZE_MAX i/o for non-devfs files. While the default becomes "don't clamp to INT_MAX", users can set `iosize_max_clamp` to 1 through sysctl. So I think applying the fix without conditioning on FreeBSD versions (i.e. the current fix) makes sense!