Re: NULL and zeros



Richard Heathfield wrote:
Christopher Layne said:


Richard Heathfield wrote:

[defensive programming yadda yadda]

I meant it is *implied* and was not written because it wasn't relevant to
the discussion at hand.


I understood what you meant by "implied", and my previous answer to that point remains valid IMHO.


You clipped my last segment.


Oops.


If a machine expressed integer 0 as all 1 bits internally, and I called
memset(&object, 0, sizeof(object)); that's going to result in object set
to all 0 bits?


Yes, it must. The machine's bizarre internal representation does not excuse the implementation from its obligations. The semantics of memset(&object, 0, sizeof(object)) is "starting at the address indicated by object, set sizeof(object) bytes to the value (unsigned char)0". If object has integer type then that process must have the effect of setting object's value to 0. If it has some other type, however, there is no such requirement.

Standard says in 7.20.3.1: "The calloc function allocates space for an array of nmemb objects, each of whose size
is size. The space is initialized to all bits zero."
It looks like "starting at the address indicated by object, set
> sizeof(object) bytes to the value (unsigned char)0" is your own
interpretation caused by the knowledge of real world computers and
compilers :)

Anyway, this newsgroup is not comp.std.c is it? So you are playing
games with standard here; you are saying "On some machines, that isn't
the case. If you are excluding such machines, you are in the wrong newsgroup.", and it's no good. Show me chunk of real world code
which will work on any machine covered by standard; or stop pretending
C doesn't mean a programming language used in real world.

The question was specifically about existence of machines with certain
properties, for a real world application, not about whether standard
says yes or no about some particular thing.

Regards,
Yevgen
.



Relevant Pages

  • Re: DAT playback issue- refresher course needed
    ... and the interfaces are nonstandard and do not actually ... They will usually work with most AES/EBU devices ... off of hours and hours of tapes (recorded on many different machines), ... standard digital I/O and a reliable transport. ...
    (rec.audio.pro)
  • Re: Accessing Apps through RWW
    ... It is Standard with 2 nics. ... When I setup the machines using the connect ... computer wizard I got a message stating that I am not authorized to view this ...
    (microsoft.public.windows.server.sbs)
  • Re: LSE64 in standard Forth
    ... complement machines for ages, so it's simply the same thing as with C: ... two's complement unless you are on a really exotic piece of hardware. ... But in Standard Forth it's not well defined, not because of the two's complement issue, but because of the size. ... Three of the four C implementations listed in K&R edition 1 are 8/16/32 bit machines. ...
    (comp.lang.forth)
  • Re: #define BITS_PER(x) (8 * sizeof(x))
    ... People are allowed to present hypothetical machines to make a point. ... (Committee oversight is not an adequate answer; ... needs to evolve, let it evolve.) ... Put in a request for it to be added to the standard. ...
    (comp.lang.c)
  • Re: Questions, please
    ... But the standard itself is a human construct. ... So why does the standard specify that -1, of all things, must cast to ... on these machines the cast ...
    (comp.lang.c)