[TUHS] Minimum Array Sizes in 16 bit C (was Maximum)

Warner Losh imp at bsdimp.com
Sun Sep 29 22:25:49 AEST 2024


On Sun, Sep 29, 2024, 4:06 AM Ralph Corderoy <ralph at inputplus.co.uk> wrote:

> Hi Werner,
>
> > > I got two letters back, saying that malloc(0) is illegal because
> > > zero-length arrays are illegal, and the other vice versa.
> >
> > And now we have zero length arrays an UB malloc(0).
>
> malloc(0) isn't undefined behaviour but implementation defined.
>

In modern C there is no difference between those two concepts.

Are there prominent modern implementations which consider it an error so
> return NULL?
>


Many.  There are a dozen or more malloc implementations in use and they all
are slightly different.

Warner

Warner

> --
> Cheers, Ralph.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.tuhs.org/pipermail/tuhs/attachments/20240929/895ae7a4/attachment.htm>


More information about the TUHS mailing list