On Sun, Sep 29, 2024, 4:06 AM Ralph Corderoy <ralph(a)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.