Re: memset all bits to zero will let float/double to zero?

From: Richard Bos (rlb_at_hoekstra-uitgeverij.nl)
Date: 06/28/04


Date: Mon, 28 Jun 2004 06:11:55 GMT


"Malcolm" <malcolm@55bank.freeserve.co.uk> wrote:

> "Keith Thompson" <kst-u@mib.org> wrote in message
> >
> > For most implementations, null pointers are represented as all-
> > bits-zero, even though using a different representation would
> > only break invalid code. Perhaps that's just inertia.
> >
> I think the main reason is psychological. foo(0) passes a NULL pointer to
> foo(), so an implementor is going to use all bits zero as the representation
> unless there is a really pressing reason to do otherwise.

Huh? Non sequitur, methinks.

> Then there's the
> problem of code that uses memset() or calloc() to intialise pointer data.

The problem is in that code, not in the non-zero representation of a
null pointer where this is useful.

Richard



Relevant Pages

  • Re: Justification for "->"?
    ... between a structure and a pointer to a structure, ... Is there a historical reason? ... of the member value, but this confuses me -- was one not allowed to ... have to chase it all over God's green earth, ...
    (comp.lang.c)
  • Re: Static variables
    ... >> void Vdlog_SetVport ... > Sounds to be for another reason. ... > and a pointer to a structure. ... Vmath_GetBox then fills in the entered co-ordinates in the *lx ...
    (comp.lang.c)
  • Re: invalid pointer adress
    ... There's no reason from a C POV why the value above would not be valid; ... You need to find out where that invalid pointer comes ... # aggregate or union type shall be constant expressions. ... A struct is an aggregate type; the address of an automatic object is not ...
    (comp.lang.c)
  • Re: Why is boost::scoped_ptr implemented this way?
    ... >> for a reason, but I cannot figure out what the reason is for not ... > delete ptr throws an exception, the scoped_ptr's state is still valid. ... These smart pointer class templates have a template parameter, T, ...
    (comp.lang.cpp)
  • Re: std::vector pointer
    ... I believe that the C++ Standard is generally similar to ... pointer to function or vice versa. ... A near pointer would point into say the data segment. ... someone will have a better reason. ...
    (alt.comp.lang.learn.c-cpp)