Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!aplcen!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.std.c Subject: Re: fwrite(buf, 0, 42, stream) == ? Message-ID: <13114@smoke.BRL.MIL> Date: 14 Jun 90 18:46:05 GMT References: <13094@smoke.BRL.MIL> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 22 In article flee@psuvax1.cs.psu.edu (Felix Lee) writes: >Doug Gwyn wrote: >>Strictly speaking, there are no semantics defined for such usage, >Well, does that mean it's undefined or implementation defined? If the >standard defines malloc(0), why not fwrite(p, 0, n, stream)? It doesn't define semantics for malloc(0) either, for exactly the same reason (the argument is the size of an object, and there are no zero- sized objects). The only requirement is that malloc() return either a pointer to at least zero bytes of (distinguishable) allocated storage or that it return a NULL pointer; the implementation may choose to do the latter. As POC for the zero-sized object extensions special interest group, I would be happier if semantics for dealing with zero-sized objects had been included in the standard, but a deliberate decision was made to outlaw them. >Urmf. If sizeof(char [n]) != n, then I can't use (c) either. But sizeof(char[n]) is n, since the byte (char) is the basic unit of storage in standard C and sizeof(char)==1 is a requirement.