https://issues.dlang.org/show_bug.cgi?id=24377

--- Comment #6 from kdevel <kde...@vogtner.de> ---
(In reply to Iain Buclaw from comment #5)
> > $ dmd -m32 nad2g.d 
> > nad2g.d(5): Error: negative array dimension `2097152u * 1024u`
> It is based on the error for static arrays.

What follows from that observation?

> ```
> Error: `char[cast(size_t)2147483648]` size 1 * 2147483648 exceeds 0x7fffffff
> size limit for static array
> ```
> 
> The hard limit is the max supported static data size for the target.

This issue is not about the static data size but about dynamic allocation.

> GCC will even warn about doing such things (i.e: malloc/calloc).
> ```
> warning: argument 1 value ‘2147483648’ exceeds maximum object size 2147483647
> ```

The GCC message is a warning not an error. And, what is more, a false positive
one [1] [2]. If you check the return value of malloc/calloc you will find that
it is not NULL. That the full 2^^32 address space is available to the user
process has been discussed in [3].

[1]
https://stackoverflow.com/questions/47450718/gcc7-2-argument-range-exceeds-maximum-object-size-9-7-werror-alloc-size-larg

[2] [GCC] Bug 85783 – alloc-size-larger-than fires incorrectly with new[] and
can't be disabled
    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85783

[3]
https://stackoverflow.com/questions/5079519/memory-limit-to-a-32-bit-process-running-on-a-64-bit-linux-os

--

Reply via email to