far pointers

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • CBFalconer

    #16
    Re: far pointers

    "Arthur J. O'Dwyer" wrote:[color=blue]
    >[/color]
    .... snip ...[color=blue]
    >
    > However, unsigned types are guaranteed to have pure binary
    > representations , which means that memsetting an 'unsigned int' to
    > zero /will/ set its value to the unsigned integer zero! Ditto
    > 'unsigned char', 'unsigned long', et cetera. (And I think ditto
    > the new C99 fixed-width types: 'int32_t' and 'int_least8_t' and
    > friends.)
    >
    > I often use 'calloc' in image processing; for example, to get
    > a grayscale image of size w*h initialized to black, I'll write
    >
    > unsigned char *im = calloc(w*h, 1);
    >
    > So 'calloc' does have its uses; they're just rare.[/color]

    I believe there is a movement for an addendum to C99 to insist on
    that all bytes zero representation of integer zeroes. AFAIK there
    are no installations extant where it doesn't work.

    The real trap is using it to initialize a pointer array to NULLs.
    Also floating point.

    --
    Chuck F (cbfalconer@yah oo.com) (cbfalconer@wor ldnet.att.net)
    Available for consulting/temporary embedded and systems.
    <http://cbfalconer.home .att.net> USE worldnet address!


    Comment

    • Michael Wojcik

      #17
      Re: far pointers


      In article <Pine.LNX.4.6 0-041.04081209355 90.1583@unix48. andrew.cmu.edu> , "Arthur J. O'Dwyer" <ajo@nospam.and rew.cmu.edu> writes:[color=blue]
      >
      > However, unsigned types are guaranteed to have pure binary
      > representations , which means that memsetting an 'unsigned int' to
      > zero /will/ set its value to the unsigned integer zero! Ditto
      > 'unsigned char', 'unsigned long', et cetera. (And I think ditto
      > the new C99 fixed-width types: 'int32_t' and 'int_least8_t' and
      > friends.)[/color]

      The signed integer types are required to have the same representation
      as their corresponding unsigned types for values that both types can
      represent (C99 6.1.2.5).

      Thus the signed integer types' zeros must also be all-bits-zero.

      Further, the "pure binary numeration system" requirement applies to
      all integral types, not just unsigned ones (also 6.1.2.5).

      --
      Michael Wojcik michael.wojcik@ microfocus.com

      Therefore, it is possible to enjoy further by using under the
      Netscape 2.0. However, Netscape will hangup at sometimes. You
      should give it up. -- roro

      Comment

      • Joona I Palaste

        #18
        Re: far pointers

        CBFalconer <cbfalconer@yah oo.com> scribbled the following:[color=blue]
        > Joona I Palaste wrote:[color=green]
        >> Harsimran <sainiharsimran @yahoo.co.in> scribbled the following:
        >>[color=darkred]
        >>> Can any one explain what are far pointers and what is the difference
        >>> between malloc and calloc .Which is better ?[/color]
        >>
        >> Far pointers are not an ISO standard C concept and are thus off-topic
        >> here. There are two differences between malloc and calloc:
        >> 1) malloc excepts one parameter, calloc excepts two. The size that[/color]
        > ^^^^^^^ ^^^^^^^
        > accepts :-)[/color]

        I actually meant "expects". But thanks for pointing out my misspelling
        anyway.

        --
        /-- Joona Palaste (palaste@cc.hel sinki.fi) ------------- Finland --------\
        \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
        "This isn't right. This isn't even wrong."
        - Wolfgang Pauli

        Comment

        • CBFalconer

          #19
          Re: far pointers

          Michael Wojcik wrote:[color=blue]
          > "Arthur J. O'Dwyer" <ajo@nospam.and rew.cmu.edu> writes:[color=green]
          >>
          >> However, unsigned types are guaranteed to have pure binary
          >> representations , which means that memsetting an 'unsigned int' to
          >> zero /will/ set its value to the unsigned integer zero! Ditto
          >> 'unsigned char', 'unsigned long', et cetera. (And I think ditto
          >> the new C99 fixed-width types: 'int32_t' and 'int_least8_t' and
          >> friends.)[/color]
          >
          > The signed integer types are required to have the same representation
          > as their corresponding unsigned types for values that both types can
          > represent (C99 6.1.2.5).
          >
          > Thus the signed integer types' zeros must also be all-bits-zero.
          >
          > Further, the "pure binary numeration system" requirement applies to
          > all integral types, not just unsigned ones (also 6.1.2.5).[/color]

          That does not follow. Integers can have trap bits. For example a
          machine with 18 bit words, 9 bit bytes could have 2 trap bits in
          integers, one marking it initialized, and one for parity. These
          don't enter into the value (which must have at least 16 bits).
          The hardware could trap on various conditions caused by an
          'all-bits-zero' setting.

          In fact many such machines exist, using 8 bit bytes with a parity
          bit added. However the parity would not be user controlled or
          read, but it could be random on uninitialized memory. ECC memory
          is another such. Here proper use requires that machine
          initialization ignore the error checks and set up the parity or
          ECC syndrome.

          --
          Chuck F (cbfalconer@yah oo.com) (cbfalconer@wor ldnet.att.net)
          Available for consulting/temporary embedded and systems.
          <http://cbfalconer.home .att.net> USE worldnet address!


          Comment

          • CBFalconer

            #20
            Re: far pointers

            Michael Wojcik wrote:[color=blue]
            > CBFalconer <cbfalconer@yah oo.com> writes:
            >[/color]
            .... snip ...[color=blue]
            >
            > Isn't it? I thought we had agreed that in effect the only integer
            > representations that met the standard's requirements were sign-
            > magnitude, one's-complement, and two's-complement. In all three,
            > all-bits-zero is a representation for value 0; the first two can
            > also express "negative zero", but I was under the impression that
            > the rule requiring same representation for corresponding signed and
            > unsigned types ruled out "negative zero" as the canonical represen-
            > tation for value 0.
            >
            > In short, initializing an array of ints or long ints to all-bits-
            > zero should, AFAICT, initialize each member of the array to value
            > 0 on any conforming implementation. What am I missing?[/color]

            Those are value bits. There may be trap bits, which are forbidden
            in unsigned char objects.

            --
            Chuck F (cbfalconer@yah oo.com) (cbfalconer@wor ldnet.att.net)
            Available for consulting/temporary embedded and systems.
            <http://cbfalconer.home .att.net> USE worldnet address!


            Comment

            • Jens.Toerring@physik.fu-berlin.de

              #21
              Re: far pointers

              CBFalconer <cbfalconer@yah oo.com> wrote:[color=blue]
              > Michael Wojcik wrote:[color=green]
              >> CBFalconer <cbfalconer@yah oo.com> writes:
              >>[/color]
              > ... snip ...[color=green]
              >>
              >> Isn't it? I thought we had agreed that in effect the only integer
              >> representations that met the standard's requirements were sign-
              >> magnitude, one's-complement, and two's-complement. In all three,
              >> all-bits-zero is a representation for value 0; the first two can
              >> also express "negative zero", but I was under the impression that
              >> the rule requiring same representation for corresponding signed and
              >> unsigned types ruled out "negative zero" as the canonical represen-
              >> tation for value 0.
              >>
              >> In short, initializing an array of ints or long ints to all-bits-
              >> zero should, AFAICT, initialize each member of the array to value
              >> 0 on any conforming implementation. What am I missing?[/color][/color]
              [color=blue]
              > Those are value bits. There may be trap bits, which are forbidden
              > in unsigned char objects.[/color]

              But wouldn't it be reasonable to assume that "The space is initialized
              to all bits zero." sentence from the standard about calloc() only
              refers to these value bits? They are the only ones the programmer is
              ever going to "see" and there's the footnote explicitely warning "Note
              that this need not be the same as the representation of floating-point
              zero or a null pointer constant." which I would tend to interpret that
              for int's and long int's that problem does not exist.

              Regards, Jens
              --
              \ Jens Thoms Toerring ___ Jens.Toerring@p hysik.fu-berlin.de
              \______________ ____________ http://www.toerring.de

              Comment

              • Mark McIntyre

                #22
                Re: far pointers

                On Thu, 12 Aug 2004 08:52:50 GMT, in comp.lang.c , "Mabden"
                <mabden@sbc_glo bal.net> wrote:
                [color=blue]
                >"Chris Torek" <nospam@torek.n et> wrote in message
                >news:cff49j0o5 2@news3.newsguy .com...[color=green]
                >> In article <news:b829bfa4. 0408112239.2a9f 242d@posting.go ogle.com>
                >> Harsimran <sainiharsimran @yahoo.co.in> wrote:[color=darkred]
                >> >and what is the difference between malloc and calloc .Which is better ?[/color]
                >>
                >> Which is better, chocolate or strawberry; coconut or soy sauce;
                >> a hammer or a wrench?[/color]
                >
                >I'd rather be hammered than wrenched...
                >
                >Coconut sauce???[/color]

                Chicken Korma.
                --
                Mark McIntyre
                CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
                CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt >


                ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
                http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
                ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---

                Comment

                • Flash Gordon

                  #23
                  Re: far pointers

                  On 12 Aug 2004 21:07:05 GMT
                  Jens.Toerring@p hysik.fu-berlin.de wrote:
                  [color=blue]
                  > CBFalconer <cbfalconer@yah oo.com> wrote:[color=green]
                  > > Michael Wojcik wrote:[color=darkred]
                  > >> CBFalconer <cbfalconer@yah oo.com> writes:
                  > >>[/color]
                  > > ... snip ...[color=darkred]
                  > >>
                  > >> Isn't it? I thought we had agreed that in effect the only integer
                  > >> representations that met the standard's requirements were sign-
                  > >> magnitude, one's-complement, and two's-complement. In all three,
                  > >> all-bits-zero is a representation for value 0; the first two can
                  > >> also express "negative zero", but I was under the impression that
                  > >> the rule requiring same representation for corresponding signed and
                  > >> unsigned types ruled out "negative zero" as the canonical represen-
                  > >> tation for value 0.
                  > >>
                  > >> In short, initializing an array of ints or long ints to all-bits-
                  > >> zero should, AFAICT, initialize each member of the array to value
                  > >> 0 on any conforming implementation. What am I missing?[/color][/color]
                  >[color=green]
                  > > Those are value bits. There may be trap bits, which are forbidden
                  > > in unsigned char objects.[/color]
                  >
                  > But wouldn't it be reasonable to assume that "The space is initialized
                  > to all bits zero." sentence from the standard about calloc() only
                  > refers to these value bits? They are the only ones the programmer is
                  > ever going to "see"[/color]

                  The programmer might access the calloced area as unsigned char, in which
                  case ALL bits are value bits, so every bit needs to be initialised to 0
                  in a calloc call. In fact, I have code at work which callocs a buffer
                  then accesses the data as unsigned char.
                  [color=blue]
                  > and there's the footnote explicitely warning "Note
                  > that this need not be the same as the representation of floating-point
                  > zero or a null pointer constant." which I would tend to interpret that
                  > for int's and long int's that problem does not exist.[/color]

                  The footnotes are not normative text, so that doesn't prove anything
                  unfortunately.
                  --
                  Flash Gordon
                  Sometimes I think shooting would be far too good for some people.
                  Although my email address says spam, it is real and I read it.

                  Comment

                  • Jens.Toerring@physik.fu-berlin.de

                    #24
                    Re: far pointers

                    Flash Gordon <spam@flash-gordon.me.uk> wrote:[color=blue]
                    > On 12 Aug 2004 21:07:05 GMT
                    > Jens.Toerring@p hysik.fu-berlin.de wrote:[/color]
                    [color=blue][color=green]
                    >> CBFalconer <cbfalconer@yah oo.com> wrote:[color=darkred]
                    >> > Michael Wojcik wrote:
                    >> >> CBFalconer <cbfalconer@yah oo.com> writes:
                    >> >>
                    >> > ... snip ...
                    >> >>
                    >> >> Isn't it? I thought we had agreed that in effect the only integer
                    >> >> representations that met the standard's requirements were sign-
                    >> >> magnitude, one's-complement, and two's-complement. In all three,
                    >> >> all-bits-zero is a representation for value 0; the first two can
                    >> >> also express "negative zero", but I was under the impression that
                    >> >> the rule requiring same representation for corresponding signed and
                    >> >> unsigned types ruled out "negative zero" as the canonical represen-
                    >> >> tation for value 0.
                    >> >>
                    >> >> In short, initializing an array of ints or long ints to all-bits-
                    >> >> zero should, AFAICT, initialize each member of the array to value
                    >> >> 0 on any conforming implementation. What am I missing?[/color]
                    >>[color=darkred]
                    >> > Those are value bits. There may be trap bits, which are forbidden
                    >> > in unsigned char objects.[/color]
                    >>
                    >> But wouldn't it be reasonable to assume that "The space is initialized
                    >> to all bits zero." sentence from the standard about calloc() only
                    >> refers to these value bits? They are the only ones the programmer is
                    >> ever going to "see"[/color][/color]
                    [color=blue]
                    > The programmer might access the calloced area as unsigned char, in which
                    > case ALL bits are value bits, so every bit needs to be initialised to 0
                    > in a calloc call. In fact, I have code at work which callocs a buffer
                    > then accesses the data as unsigned char.[/color]
                    [color=blue][color=green]
                    >> and there's the footnote explicitely warning "Note
                    >> that this need not be the same as the representation of floating-point
                    >> zero or a null pointer constant." which I would tend to interpret that
                    >> for int's and long int's that problem does not exist.[/color][/color]
                    [color=blue]
                    > The footnotes are not normative text, so that doesn't prove anything
                    > unfortunately.[/color]

                    Thanks. That of course leaves one wondering why calloc() takes two
                    arguments at all when it actually can be called safely only in
                    cases were the second one is 1 - but that could be due to historic
                    reasons, i.e. it was originally meant to allow initialization of
                    e.g. int arrays but for some reasons that couldn't be kept that
                    way.

                    But then there's still the memset() function. Do the same restrictions
                    apply as for calloc() or can it be safely used for intitialization of
                    an int array with zeros? The "into each of the first n characters" bit
                    seems to hint at the same problem as with calloc()...

                    Regards, Jens
                    --
                    \ Jens Thoms Toerring ___ Jens.Toerring@p hysik.fu-berlin.de
                    \______________ ____________ http://www.toerring.de

                    Comment

                    • Edd

                      #25
                      Re: far pointers

                      Harsimran wrote:[color=blue]
                      > Can any one explain what are far pointers and what is the difference
                      > between malloc and calloc .Which is better ?[/color]

                      I believe others have answered your question perfectly well, but while we're on
                      the subject I'd like to ask about something that's been niggling me for a while now.

                      One of my C programming books (A Book On C 4th edition, Kelley & Pohl) has the
                      following to say about malloc and calloc (page 663):


                      void *calloc(size_t n, size_t el_size);
                      Allocates contiguous space in memory for an array of n elements, with each
                      element requiring el_size bytes. The space is initialized with all bits set to
                      zero. A successful call returns the base address of the allocated space;
                      otherwise, NULL is returned.

                      void *malloc(size_t size);
                      Allocates a block in memory consisting of size bytes. The space is not
                      initialized. A successful call returns the base address of the allocated space;
                      otherwise, NULL is returned.


                      The niggle of which I speak is with respect to the "contiguous " part of the
                      calloc description; is the space allocated by a successful malloc call not
                      necessarily required to be contiguous?

                      I don't have a copy of the standard (yet) and so I'd really appreciate it if
                      someone could clear this up for me. As far as I can see, it would be daft for
                      malloc-ated space not to be contiguous?

                      Thanks.

                      Edd

                      Comment

                      • Emmanuel Delahaye

                        #26
                        Re: far pointers

                        Edd wrote on 13/08/04 :[color=blue]
                        > void *malloc(size_t size);
                        > Allocates a block in memory consisting of size bytes. The space is not
                        > initialized. A successful call returns the base address of the allocated
                        > space; otherwise, NULL is returned.
                        >
                        > The niggle of which I speak is with respect to the "contiguous " part of the
                        > calloc description; is the space allocated by a successful malloc call not
                        > necessarily required to be contiguous?[/color]

                        No. Like for calloc() and realloc(), it has to be contiguous and well
                        aligned.

                        <ISO/IEC 9899:1999 (E)>
                        7.20.3 Memory management functions
                        1 The order and contiguity of storage allocated by successive calls to
                        the calloc,
                        malloc, and realloc functions is unspecified. The pointer returned if
                        the allocation
                        succeeds is suitably aligned so that it may be assigned to a pointer to
                        any type of object
                        and then used to access such an object or an array of such objects in
                        the space allocated
                        (until the space is explicitly deallocated). The lifetime of an
                        allocated object extends
                        from the allocation until the deallocation. Each such allocation shall
                        yield a pointer to an
                        object disjoint from any other object. The pointer returned points to
                        the start (lowest byte
                        address) of the allocated space. If the space cannot be allocated, a
                        null pointer is
                        returned. If the size of the space requested is zero, the behavior is
                        implementationd efined:
                        either a null pointer is returned, or the behavior is as if the size
                        were some
                        nonzero value, except that the returned pointer shall not be used to
                        access an object.
                        7.20.3.1 The calloc function
                        Synopsis
                        1 #include <stdlib.h>
                        void *calloc(size_t nmemb, size_t size);
                        Description
                        2 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.252)
                        Returns
                        3 The calloc function returns either a null pointer or a pointer to the
                        allocated space.
                        </>

                        --
                        Emmanuel
                        The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html

                        "C is a sharp tool"

                        Comment

                        • Chris Torek

                          #27
                          malloc vs calloc (was Re: far pointers)

                          In article <news:cfh6mc$dp i$1@news7.svr.p ol.co.uk>
                          Edd <edd@NOSPAMHERE nunswithguns.ne t> wrote:[color=blue]
                          >... while we're on the subject I'd like to ask about something
                          >that's been niggling me for a while now.[/color]
                          [color=blue]
                          >One of my C programming books (A Book On C 4th edition, Kelley &
                          >Pohl) has the following to say about malloc and calloc (page 663):[/color]

                          [wording snipped, but calloc()'s description contains the word
                          "contiguous " while malloc()'s does not]
                          [color=blue]
                          >The niggle of which I speak is with respect to the "contiguous " part of the
                          >calloc description; is the space allocated by a successful malloc call not
                          >necessarily required to be contiguous?[/color]

                          Both return a contiguous memory region.

                          The calloc() description is "more deserving" of the extra word for
                          one simple reason: malloc() gets only one parameter -- the number
                          of bytes to allocate -- while calloc() gets two. Since "there is
                          no magic" (or was, at least, when C was first being written -- ISO
                          now allows arbitrary amounts of magic to occur between the compiler
                          and its Standard C library), a call of the form:

                          malloc(32)

                          is unable to tell whether you wanted 8 four-byte objects (e.g.,
                          malloc(n_obj * sizeof *obj) where n_obj is 8 and sizeof *obj is 4)
                          or whether you wanted a single 32-byte object (e.g.,
                          malloc(sizeof *obj2) where sizeof *obj2 is 32). On the other
                          hand, calloc gets a separate "number of objects" and "size of
                          each object":

                          calloc(n_obj, sizeof *obj) /* for the first case */
                          vs calloc(1, sizeof *obj2) /* for the second case */

                          Obviously calloc() has more information than malloc() -- so it
                          might, conceivably, be able to use that to call malloc() N times
                          instead of just once (and indeed, there was once a cfree() that
                          was to be used on calloc()'ed memory, and perhaps cfree() might
                          then call free() N times as well). If calloc() were allowed to
                          do that, it could get N discontiguous regions, and perhaps
                          chain them together into a linked list or something.

                          It does not do that, of course; and you free() the pointers you
                          get from calloc() just as you free() those from malloc(), so calloc()
                          just has to multiply its two parameters together (and check for
                          overflow). But because calloc() has, at first glance, enough
                          information to malloc() N times, the extra word "contiguous " has
                          some reason for being there, however weak that reason turns out to
                          be in the end.
                          --
                          In-Real-Life: Chris Torek, Wind River Systems
                          Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
                          email: forget about it http://web.torek.net/torek/index.html
                          Reading email is like searching for food in the garbage, thanks to spammers.

                          Comment

                          • CBFalconer

                            #28
                            Re: far pointers

                            Jens.Toerring@p hysik.fu-berlin.de wrote:[color=blue]
                            >
                            > CBFalconer <cbfalconer@yah oo.com> wrote:[color=green]
                            > > Michael Wojcik wrote:[color=darkred]
                            > >> CBFalconer <cbfalconer@yah oo.com> writes:
                            > >>[/color]
                            > > ... snip ...[color=darkred]
                            > >>
                            > >> Isn't it? I thought we had agreed that in effect the only integer
                            > >> representations that met the standard's requirements were sign-
                            > >> magnitude, one's-complement, and two's-complement. In all three,
                            > >> all-bits-zero is a representation for value 0; the first two can
                            > >> also express "negative zero", but I was under the impression that
                            > >> the rule requiring same representation for corresponding signed and
                            > >> unsigned types ruled out "negative zero" as the canonical represen-
                            > >> tation for value 0.
                            > >>
                            > >> In short, initializing an array of ints or long ints to all-bits-
                            > >> zero should, AFAICT, initialize each member of the array to value
                            > >> 0 on any conforming implementation. What am I missing?[/color][/color]
                            >[color=green]
                            > > Those are value bits. There may be trap bits, which are forbidden
                            > > in unsigned char objects.[/color]
                            >
                            > But wouldn't it be reasonable to assume that "The space is initialized
                            > to all bits zero." sentence from the standard about calloc() only
                            > refers to these value bits? They are the only ones the programmer is
                            > ever going to "see" and there's the footnote explicitely warning "Note
                            > that this need not be the same as the representation of floating-point
                            > zero or a null pointer constant." which I would tend to interpret that
                            > for int's and long int's that problem does not exist.[/color]

                            But calloc initializes bytes. Integers may occupy an integral
                            number of bytes, but they do NOT have to use all of their bits as
                            value bits. Admittedly such an actual machine would be unusual
                            and probably have marketing problems, but it is not foreclosed by
                            the C standard.

                            --
                            Chuck F (cbfalconer@yah oo.com) (cbfalconer@wor ldnet.att.net)
                            Available for consulting/temporary embedded and systems.
                            <http://cbfalconer.home .att.net> USE worldnet address!


                            Comment

                            • CBFalconer

                              #29
                              Re: far pointers

                              Jens.Toerring@p hysik.fu-berlin.de wrote:[color=blue]
                              >[/color]
                              .... snip ...[color=blue]
                              >
                              > But then there's still the memset() function. Do the same restrictions
                              > apply as for calloc() or can it be safely used for intitialization of
                              > an int array with zeros? The "into each of the first n characters" bit
                              > seems to hint at the same problem as with calloc()...[/color]

                              No. It is not presently guaranteed.

                              --
                              Chuck F (cbfalconer@yah oo.com) (cbfalconer@wor ldnet.att.net)
                              Available for consulting/temporary embedded and systems.
                              <http://cbfalconer.home .att.net> USE worldnet address!


                              Comment

                              • Jens.Toerring@physik.fu-berlin.de

                                #30
                                Re: far pointers

                                CBFalconer <cbfalconer@yah oo.com> wrote:[color=blue]
                                > Jens.Toerring@p hysik.fu-berlin.de wrote:[color=green]
                                >>
                                >> CBFalconer <cbfalconer@yah oo.com> wrote:[color=darkred]
                                >> > Michael Wojcik wrote:
                                >> >> CBFalconer <cbfalconer@yah oo.com> writes:
                                >> >>
                                >> > ... snip ...
                                >> >>
                                >> >> Isn't it? I thought we had agreed that in effect the only integer
                                >> >> representations that met the standard's requirements were sign-
                                >> >> magnitude, one's-complement, and two's-complement. In all three,
                                >> >> all-bits-zero is a representation for value 0; the first two can
                                >> >> also express "negative zero", but I was under the impression that
                                >> >> the rule requiring same representation for corresponding signed and
                                >> >> unsigned types ruled out "negative zero" as the canonical represen-
                                >> >> tation for value 0.
                                >> >>
                                >> >> In short, initializing an array of ints or long ints to all-bits-
                                >> >> zero should, AFAICT, initialize each member of the array to value
                                >> >> 0 on any conforming implementation. What am I missing?[/color]
                                >>[color=darkred]
                                >> > Those are value bits. There may be trap bits, which are forbidden
                                >> > in unsigned char objects.[/color]
                                >>
                                >> But wouldn't it be reasonable to assume that "The space is initialized
                                >> to all bits zero." sentence from the standard about calloc() only
                                >> refers to these value bits? They are the only ones the programmer is
                                >> ever going to "see" and there's the footnote explicitely warning "Note
                                >> that this need not be the same as the representation of floating-point
                                >> zero or a null pointer constant." which I would tend to interpret that
                                >> for int's and long int's that problem does not exist.[/color][/color]
                                [color=blue]
                                > But calloc initializes bytes. Integers may occupy an integral
                                > number of bytes, but they do NOT have to use all of their bits as
                                > value bits. Admittedly such an actual machine would be unusual
                                > and probably have marketing problems, but it is not foreclosed by
                                > the C standard.[/color]

                                Thanks for your (and everyone else's) replies.

                                Regards, Jens
                                --
                                \ Jens Thoms Toerring ___ Jens.Toerring@p hysik.fu-berlin.de
                                \______________ ____________ http://www.toerring.de

                                Comment

                                Working...