Topic: comparison to NULL pointer


Author: kanze@gabi-soft.fr (J. Kanze)
Date: 1996/12/01
Raw View
Darron.Shaffer@beasys.com (Darron Shaffer) writes:

> "Bill Wade" <bill.wade@stoner.com> wrote:
> >
> >I'm sure Steve knows this, but there are a couple of situations where you
> >can't just use 0 as a null pointer constant.
> >
> >1) In C and C++ a varargs argument (one of the ... arguments) will need the
> >0 cast to the correct pointer type.
> >  void bar(int i,...); // if i==72, next argument is a void*
> >  bar(72, 0);   // Not portable unless the 0 is cast to void*.
> >
> >2) In some cases the 0 will need to be cast to resolve an overloading
> >ambiguity in C++:
> >  void foo(void*);
> >  void foo(int);
> >  foo(0);       // Does not call foo(void*)
>
> This sounds like an instance where a reserved word (null?) that provides a
> generic pointer type with the value NULL would be useful.  This would
> require special conversion rules (like zero).
>
> It would not only be self-documenting but would eliminate the need for a
> cast.  (always a good thing, IMHO).
>
> BTW, this is NOT certain to fix the problems with the varargs case -- some
> pointer types may be different sizes on some machines.

Such a pointer would have a totally new, very special type.  If the
language were to adapt such a position, then it would not require very
much to make it illegal to pass this type to a vararg; passing an uncast
"null" to a vararg would then require a compiler diagnostic.

--
James Kanze         +33 (0)3 88 14 49 00         email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
Conseils en informatique industrielle --
                            -- Beratung in industrieller Datenverarbeitung


[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: Jason Merrill <jason@cygnus.com>
Date: 1996/11/24
Raw View
>>>>> Fergus Henderson <fjh@mundook.cs.mu.OZ.AU> writes:

>> This sounds like an instance where a reserved word (null?) that provides a
>> generic pointer type with the value NULL would be useful.  This would
>> require special conversion rules (like zero).

> This was discussed a lot on the newsgroups a year or so ago.

And I fairly recently implemented it in g++; NULL is now defined to __null, a
magic null pointer constant of type void*, distinct from (void *)0.
In strict compliance mode, __null has the integral type which is the same
size as a pointer (necessary since 'int i = NULL' is well-formed, if
strange).

Jason
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: martelli@cadlab.it (Alex Martelli)
Date: 1996/11/25
Raw View
Darron.Shaffer@beasys.com (Darron Shaffer) writes:
 ...
>>2) In some cases the 0 will need to be cast to resolve an overloading
>>ambiguity in C++:
>>  void foo(void*);
>>  void foo(int);
>>  foo(0);       // Does not call foo(void*)

>This sounds like an instance where a reserved word (null?) that provides a
>generic pointer type with the value NULL would be useful.  This would
>require special conversion rules (like zero).

I don't think this often-proposed ad hoc solution would do much that
is useful; it might help on the case above, but would do absolutely
nothing for the perhaps more common case of, say,

 void bar(int *);
 void bar(char *);

 foo(null); // ambiguous?!

Expressing the type precisely would require a parameterized construct:

 foo(nil<int>);
 foo(nil<char>);

And you can get very close to this syntax today, by writing nil<> as
a template, except that you need an extra pair of parentheses on using
it (either to construct a temporary object that will implicitly be
converted to the appropriately-typed null pointer, or to call an inline
templated function for the same purpose).

>BTW, this is NOT certain to fix the problems with the varargs case -- some
>pointer types may be different sizes on some machines.

While a parameterized nil<> template will fix that case too, just as
smoothly -- and requires no addition to the language as it stands.


Alex
--
DISCLAIMER: these are MY personal opinions and viewpoints, NOT connected
in any way with my employer, nor any other organization or individual!
Email: martelli@cadlab.it -- Phone: +39 (51) 597 313  [Fax: 597 120]
Cad.Lab S.p.A., v. Ronzani 7/29, 40033 Casalecchio (BO), Italia
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: fjh@murlibobo.cs.mu.OZ.AU (Fergus Henderson)
Date: 1996/11/25
Raw View
martelli@cadlab.it (Alex Martelli) writes:

>Darron.Shaffer@beasys.com (Darron Shaffer) writes:
> ...
>>>2) In some cases the 0 will need to be cast to resolve an overloading
>>>ambiguity in C++:
>>>  void foo(void*);
>>>  void foo(int);
>>>  foo(0);       // Does not call foo(void*)
>
>>This sounds like an instance where a reserved word (null?) that provides a
>>generic pointer type with the value NULL would be useful.

Yes.  There are two issues here.  One is using a name like `null' or
`NULL', so that you can write clear code that says what you mean.
The other issue is making sure that the compiler's interpretation of
the code matches your interpretation.  `NULL' is helpful for the
former, but the above code is a nasty trap that is easy to fall into
if you get into the habit of thinking of `NULL' as a real null pointer
constant.  That's why a _working_ NULL would be a really good idea.

>I don't think this often-proposed ad hoc solution would do much that
>is useful; it might help on the case above, but would do absolutely
>nothing for the perhaps more common case of, say,
>
> void bar(int *);
> void bar(char *);
>
> foo(null); // ambiguous?!

This is something that is _much_ less of a worry than
the previous problem, because here the ambiguity is
diagnosed at compile time, whereas in the previous
example C++ just silently picks the wrong function.

In this case, the programmer can easily cast null to whichever
type is appropriate (using implicit_cast, of course ;-).

>Expressing the type precisely would require a parameterized construct:
>
> foo(nil<int>);
> foo(nil<char>);
>
>And you can get very close to this syntax today, by writing nil<> as
>a template, except that you need an extra pair of parentheses on using
>it (either to construct a temporary object that will implicitly be
>converted to the appropriately-typed null pointer, or to call an inline
>templated function for the same purpose).

If you're willing to use macros, then you can get exactly this syntax:

 template <class T>
 struct null {
  static T * const pointer = 0;
 };
 #define nil null::pointer

However, that would be missing the point, IMHO.

In the normal case, you _don't_ want to have to specify the type of
every null pointer; it's usually much more convenient if the compiler
infers the type based on the target of the assignment.  That's why
people use `NULL', rather than `NIL(Some_Very_Long_Type_Name)'.
Explicitly specifying the type of every null pointer would be a waste
of time, if the language was really type-safe.  (To consider a related
example, functional programmers certainly don't specify the type of every
empty list!)  As it is, however, the presence of varargs, and given
the brokenness of NULL in cases like the one at the top of this post,
I guess it is not such a bad idea.

--
Fergus Henderson <fjh@cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3         |     -- the last words of T. S. Garp.
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: fjh@mundook.cs.mu.OZ.AU (Fergus Henderson)
Date: 1996/11/26
Raw View
While suffering from lack of caffeine, I wrote the following:

>martelli@cadlab.it (Alex Martelli) writes:
>
>> foo(nil<int>);
>
>If you're willing to use macros, then you can get exactly this syntax:
>
> template <class T>
> struct null {
>  static T * const pointer = 0;
> };
> #define nil null::pointer

Of course, that won't work; `nil<int>' becomes `null::pointer<int>'
rather than `null<int>::pointer'.  Oops.

--
Fergus Henderson <fjh@cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3         |     -- the last words of T. S. Garp.


[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: clamage@taumet.eng.sun.com (Steve Clamage)
Date: 1996/11/21
Raw View
In article 505C@hpbbn.bbn.hp.com, Ralf Asmus <rasmus@hpbbn.bbn.hp.com> writes:
>I want to have portable code and don't know, whether it is
>ok to assign NULL to a pointer or compare a pointer to NULL.
>Or it would be better to do this via (<cast to pointer type>)0.
>What is the exact definition of NULL in Ansi C++ ?
>Is it fix and if yes, since when ?

The status of NULL, null pointer constants, and null pointers has not
changed in C++, and is fundamentally the same as in Standard C.

The macro NULL is a null pointer constant defined in several headers.
In C++ you can always use a literal zero for a null pointer constant,
just as in C. C also allows, for example, (void*)0 as a null pointer
constant, but that doesn't work correctly in C++ as explained below.

You can compare or assign (without a cast) a null pointer constant to
any pointer or pointer-to-member. When converted to the same type,
any two null pointers compare equal, and each compares equal
to a null pointer constant. Further, no valid pointer to any
object or function or class member ever compares equal to any
null pointer of the same type, nor to a null pointer constant.

Unlike C, conversions from void* to any other pointer type requires
an explicit cast, so (void*)0 is not a suitable choice for a null
pointer constant in C++.

In C++ as well as in C, the use of a null pointer constant might not
be correct when passing arguments to the unspecified parameters
(ellipsis) of a variadic function, because the compiler cannot tell
what type the function expects to receive. Example:
 void f(int, ...); // declaration
 f(1, NULL);       // call
Assuming NULL evaluates to a literal 0, the value zero will be passed as
an int. If function f expects to see a pointer as the second argument,
that might or might not work. In this case, you would want to cast NULL
(or 0) to the type of pointer that the function expects to receive.
 f(1, (char*)0); // C or C++
I think this is the only case where you should use a cast with a null
pointer constant.

Finally, please notice that we haven't said anything about how
null pointers are represented in the machine. They can be all-bits-
zero or something else, as long as the conditions above are met. A
literal zero in source code interpreted as a pointer gets converted
to a null pointer constant by the compiler.
---
Steve Clamage, stephen.clamage@eng.sun.com




[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: Alexandre Oliva <oliva@dcc.unicamp.br>
Date: 1996/11/21
Raw View
Ralf Asmus writes:

> I want to have portable code and don't know, whether it is
> ok to assign NULL to a pointer or compare a pointer to NULL.

AFAIK, it is totally portable.  I can't think of any portability
problem related to null pointers, as long as they are not
dereferenced.

> Or it would be better to do this via (<cast to pointer type>)0.

There's no difference at all, but I'd avoid casting when unnecessary
(personal preference).  Anyway, instead of a C-style cast, write
static_cast<pointer type>(0), if you really want to cast explicitly.

> What is the exact definition of NULL in Ansi C++ ?=20

There's no ANSI C++ yet, but the current (Sept'96) draft working paper
says:

  4.10  Pointer conversions                                   [conv.ptr]
1 An integral constant expression (_expr.const_) rvalue of integer  type
  that  evaluates  to  zero (called a null pointer constant) can be con=AD
  verted to a pointer type.  The result is  a  value  (called  the  null
  pointer  value  of that type) distinguishable from every pointer to an
  object or function.

--=20
Alexandre Oliva
mailto:oliva@dcc.unicamp.br
Universidade Estadual de Campinas, SP, Brasil


[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: fjh@mundook.cs.mu.OZ.AU (Fergus Henderson)
Date: 1996/11/22
Raw View
Ralf Asmus <rasmus@hpbbn.bbn.hp.com> writes:

>I want to have portable code and don't know, whether it is
>ok to assign NULL to a pointer or compare a pointer to NULL.

Yes, this is fine in standard C++, presuming you have #included one of
the standard header files that defines NULL.

>Or it would be better to do this via (<cast to pointer type>)0.

I find NULL more readable, but that's a style issue which is
best suited for some other newsgroup.

--
Fergus Henderson <fjh@cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3         |     -- the last words of T. S. Garp.
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: "Bill Wade" <bill.wade@stoner.com>
Date: 1996/11/22
Raw View
Steve Clamage <clamage@taumet.eng.sun.com> wrote in article

[ Context removed]

> In C++ you can always use a literal zero for a null pointer constant,
> just as in C.

I'm sure Steve knows this, but there are a couple of situations where you
can't just use 0 as a null pointer constant.

1) In C and C++ a varargs argument (one of the ... arguments) will need the
0 cast to the correct pointer type.
  void bar(int i,...); // if i==72, next argument is a void*
  bar(72, 0); // Not portable unless the 0 is cast to void*.

2) In some cases the 0 will need to be cast to resolve an overloading
ambiguity in C++:
  void foo(void*);
  void foo(int);
  foo(0); // Does not call foo(void*)
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: clamage@taumet.eng.sun.com (Steve Clamage)
Date: 1996/11/23
Raw View
In article 6064370a@wow, "Bill Wade" <bill.wade@stoner.com> writes:
>Steve Clamage <clamage@taumet.eng.sun.com> wrote in article
>
>[ Context removed]
>
>> In C++ you can always use a literal zero for a null pointer constant,
>> just as in C.
>
>I'm sure Steve knows this, but there are a couple of situations where you
>can't just use 0 as a null pointer constant.
>
>1) In C and C++ a varargs argument (one of the ... arguments) will need the
>0 cast to the correct pointer type.
>  void bar(int i,...); // if i==72, next argument is a void*
>  bar(72, 0); // Not portable unless the 0 is cast to void*.

Yes, and I said exactly that in the article you quoted from.


>2) In some cases the 0 will need to be cast to resolve an overloading
>ambiguity in C++:
>  void foo(void*);
>  void foo(int);
>  foo(0); // Does not call foo(void*)

I probably should have been more precise. A literal zero has type int, but
can be converted implicitly to a null pointer constant.

In this example, the literal zero (type int) is an exact match for foo(int),
and so there is no ambiguity.

---
Steve Clamage, stephen.clamage@eng.sun.com
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: Chelly Green <chelly@eden.com>
Date: 1996/11/23
Raw View
Bill Wade wrote:
>
...
> 1) In C and C++ a varargs argument (one of the ... arguments) will need the
> 0 cast to the correct pointer type.
>   void bar(int i,...); // if i==72, next argument is a void*
>   bar(72, 0);   // Not portable unless the 0 is cast to void*.

And even then, it *must* expect a void*. If you casted to an int*, but
it expected a void*, it would not necessarily work. void* and int* may
be represented differently. Or worse, it expects a Base*, but you give
it a Derived*, where multiple inheritance is involved, so the proper
pointer adjustment is not performed. Yet another reason why variable
argument functions should die!  :-)

...

--
Chelly Green | chelly@eden.com | C++ - http://www.eden.com/~chelly
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: Darron.Shaffer@beasys.com (Darron Shaffer)
Date: 1996/11/23
Raw View
"Bill Wade" <bill.wade@stoner.com> wrote:
>
>I'm sure Steve knows this, but there are a couple of situations where you
>can't just use 0 as a null pointer constant.
>
>1) In C and C++ a varargs argument (one of the ... arguments) will need the
>0 cast to the correct pointer type.
>  void bar(int i,...); // if i==72, next argument is a void*
>  bar(72, 0);   // Not portable unless the 0 is cast to void*.
>
>2) In some cases the 0 will need to be cast to resolve an overloading
>ambiguity in C++:
>  void foo(void*);
>  void foo(int);
>  foo(0);       // Does not call foo(void*)

This sounds like an instance where a reserved word (null?) that provides a
generic pointer type with the value NULL would be useful.  This would
require special conversion rules (like zero).

It would not only be self-documenting but would eliminate the need for a
cast.  (always a good thing, IMHO).

BTW, this is NOT certain to fix the problems with the varargs case -- some
pointer types may be different sizes on some machines.


Darron
--
Darron Shaffer
Darron.Shaffer@beasys.com
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: fjh@mundook.cs.mu.OZ.AU (Fergus Henderson)
Date: 1996/11/23
Raw View
Darron.Shaffer@beasys.com (Darron Shaffer) writes:

>"Bill Wade" <bill.wade@stoner.com> wrote:
>>
>>2) In some cases the 0 will need to be cast to resolve an overloading
>>ambiguity in C++:
>>  void foo(void*);
>>  void foo(int);
>>  foo(0);       // Does not call foo(void*)
>
>This sounds like an instance where a reserved word (null?) that provides a
>generic pointer type with the value NULL would be useful.  This would
>require special conversion rules (like zero).
>
>It would not only be self-documenting but would eliminate the need for a
>cast.  (always a good thing, IMHO).

This was discussed a lot on the newsgroups a year or so ago.
The disadvantage of your suggestion is that it would make the
type system more complicated.  There are a few tricky issues,
such as

 template <class T> void foo(T);
 void bar() { foo(null); }

What type

There was a proposal to make `(void *)0' be a null pointer constant.
This is a lot simpler, since it just requires changing the definition
of "null pointer constant" in 4.10[conv.ptr]/1, and the change
is just to add
 ..., or such an expression cast to type "pointer to cv void", ...
in the appropriate place.  This would not have required inventing
a whole new set of rules for `null'.  It would also have avoided
breaking code by adding a new keyword.

If this proposal had been accepted, and NULL was required to be defined
as `(void *)0', then this would have avoided the need to cast NULL to
avoid the ambiguity problem for overloaded functions.

However, this proposal was rejected by the committee.

--
Fergus Henderson <fjh@cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3         |     -- the last words of T. S. Garp.
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: claus@faerber.muc.de (=?ISO-8859-1?Q?Claus_Andr=E9_F=E4rber?=)
Date: 1996/11/24
Raw View
Hallo Bill, hallo everybody,

Bill Wade <bill.wade@stoner.com> wrote on 22 Nov 96:
> Steve Clamage <clamage@taumet.eng.sun.com> wrote in article
>
> [ Context removed]
>
> > In C++ you can always use a literal zero for a null pointer
> > constant, just as in C.
>
> I'm sure Steve knows this, but there are a couple of situations
> where you can't just use 0 as a null pointer constant.

... neither can you use a constant like "NULL", which is usually =20
defined as "0".
Thus "0" and "NULL" are equivalent.

>   void bar(int i,...); // if i=3D=3D72, next argument is a void*
>   bar(72, 0); // Not portable unless the 0 is cast to void*.

bar(72, NULL); // again not portable

>   void foo(void*);
>   void foo(int);
>   foo(0); // Does not call foo(void*)

foo(NULL); // will also call foo(int)

--=20
Claus Andr=E9 F=E4rber <claus@faerber.muc.de>, <http://www.muc.de/~cfaerb=
er/>
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: Ralf Asmus <rasmus@hpbbn.bbn.hp.com>
Date: 1996/11/21
Raw View
I want to have portable code and don't know, whether it is
ok to assign NULL to a pointer or compare a pointer to NULL.
Or it would be better to do this via (<cast to pointer type>)0.
What is the exact definition of NULL in Ansi C++ ?
Is it fix and if yes, since when ?

Thanks, Ralf
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]