https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67999
Rich Felker <bugdal at aerifal dot cx> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bugdal at aerifal dot cx
--- Comment #6 from Rich Felker <bugdal at aerifal dot cx> ---
IMO there's nothing wrong with what GCC's doing, but library implementations
that allow allocations > PTRDIFF_MAX are buggy. musl has always gotten this
right and Bionic has fixed it recently; see
https://android-review.googlesource.com/#/c/170800/
Somebody should probably file a bug with glibc if there's not one already, but
clearly they're aware of this issue (Alexander Cherepanov pointed this out to
me): https://sourceware.org/ml/libc-alpha/2011-12/msg00066.html
The key part is:
"I don't think there's anything that can sensibly be done in the compiler
about this issue; I think the only way to avoid security problems there is
for malloc and other allocation functions to refuse to allocate objects
using half or more of the address space..."