<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Sep 29, 2024, 4:06 AM Ralph Corderoy <<a href="mailto:ralph@inputplus.co.uk">ralph@inputplus.co.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Werner,<br>
<br>
> > I got two letters back, saying that malloc(0) is illegal because<br>
> > zero-length arrays are illegal, and the other vice versa.<br>
><br>
> And now we have zero length arrays an UB malloc(0).<br>
<br>
malloc(0) isn't undefined behaviour but implementation defined.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">In modern C there is no difference between those two concepts.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Are there prominent modern implementations which consider it an error so<br>
return NULL?<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto">Many. There are a dozen or more malloc implementations in use and they all are slightly different. </div><div dir="auto"><br></div><div dir="auto">Warner</div><div dir="auto"><br></div><div dir="auto">Warner </div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-- <br>
Cheers, Ralph.<br>
</blockquote></div></div></div>