Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: Isn't that beauty ? (no it's not)
Date: Sun, 15 Mar 2026 14:38:06 -0700
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <86tsug6af5.fsf@linuxsc.com>
References: <10otm7r$1ntrg$1@raubtier-asyl.eternal-september.org> <10ougtt$21vgj$1@dont-email.me> <10ouhm6$22rm2$1@raubtier-asyl.eternal-september.org> <10ouje5$21vgj$5@dont-email.me> <10oul1g$241b4$1@raubtier-asyl.eternal-september.org> <10ov73a$2bugo$3@dont-email.me> <10p03uu$2nho7$1@dont-email.me> <10p07kn$2pg89$1@dont-email.me> <10p246s$30r9e$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Sun, 15 Mar 2026 21:38:09 +0000 (UTC)
Injection-Info: dont-email.me; posting-host="37fbd2bc0a39a2e0da8dcfefffa00bf6"; logging-data="1460169"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18yTdgZfWj6VheKfseMQpsj7qLiZn06+9E="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:/CxfL2Uy5hT7+/jlS6lu2Pz1kAk= sha1:/ugMV/fN2b62NWMI5Lp6b/JEX+o=
Xref: csiph.com comp.lang.c:397007
James Kuyper writes:
> DFS writes:
> ...
>
>> Question: wordlist was malloced with a size of 0:
>>
>> wordlist = malloc(wordcount * sizeof(const char *));
>>
>> Why are you allowed to malloc size 0?
>
> Because, in some contexts, it's convenient to allow a mixture of
> 0-sized and non-zero sized allocations, depending upon the value of
> a variable, so some pre-standard versions of malloc() supported
> malloc(0) returning a unique pointer to memory that could not be
> accessed. The uniqueness of the pointer allowed the value of the
> pointer to be used as an identifier for the thing that might or
> might not have been allocated.
> This was a sufficiently common feature that the C committee decided
> to allow it, but sufficiently rare that the C committee decided not
> to mandate it.
The explanation offered by Scott Lurndal is more convincing. The
rule was put in to accommodate both AT&T Unix and BSD Unix. There
is no reason in evidence to suggest there was any evaluation by
the C committee; they allowed both behaviors because the two main
branches of Unix at the time had made different decisions.