From: fred@genesis.demon.co.uk (Lawrence Kirby)
Subject: Re: Programming language vote - results
Date: 1997/11/27
Date: 1997-11-27T00:00:00+00:00 [thread overview]
Message-ID: <880643794snz@genesis.demon.co.uk> (raw)
In-Reply-To: 65ih8m$pqt$1@news1.ucsd.edu
In article <65ih8m$pqt$1@news1.ucsd.edu>
wtanksle@sdcc10.ucsd.edu "William Tanksley" writes:
...
>NULL is defined as "(void*)0".
It could also be written as #define NULL 0 in C, and it must be written like
that in C++.
> I've never seen a compiler which failed to
>have (int)NULL be equal to 0 as well, but seeing one would not shock me --
>according to K&R 2 (I don't have ANS C available right now) ANS doesn't
>explicitly require that.
That is correct - converting a pointer to an integer has
an implementation-defined result if it will fit in the integer, undefined
if not. There are no special cases for conversion in that direction.
>The worst part of that code, as far as I'm concerned, isn't the use of
>pointers as booleans; after all, I can't imagine why a vendor would EVER
>make non-zero NULL returns, especially since it would have to do a LOT of
>work to make them meet the other requirements.
Actually that's not true. All the implementor has to do is that ensure that
whenever a null pointer constant is converted to a pointer type, the
result has the correct representation for a null pointer of that type.
For comparison against zero you can simply take the view that the zero
is converted to the appropriate pointer type so the comparison simply
works.
> The bad part is that it
>assumes that a pointer in an unknown state will be either NULL or
>allocated. Ick. However, it could be that all the other code in the
>application is a model of clear and precise code, so those are obviously
>the only two possible states of the pointer at that point. If so, that's
>acceptable code.
A pointer value can be one of the following in C:
1. null
2. a pointer to a valid object (or function for a function pointer)
3. a pointer to one past the end of a valid object
4. Indeterminate.
In the last case it is not valid to even look at the value in the code.
Indeterminate pointers are, for example:
1. the values of uninitialised automatic variables
2. a pointer to an automatic variable which has since been destroyed
because the function defining it returned or was longjmp'd out of
3. a pointer to dynamic memory that has been freed
4. a pointer to a FILE that has been closed.
--
-----------------------------------------
Lawrence Kirby | fred@genesis.demon.co.uk
Wilts, England | 70734.126@compuserve.com
-----------------------------------------
next prev parent reply other threads:[~1997-11-27 0:00 UTC|newest]
Thread overview: 147+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <343fbb5a.0@news.iprolink.ch>
1997-10-11 0:00 ` Programming language vote - results Gary L. Scott
1997-10-12 0:00 ` Jack Rudd
1997-10-13 0:00 ` Robert Munck
1997-10-13 0:00 ` Jack Rudd
1997-10-13 0:00 ` Gary L. Scott
1997-10-13 0:00 ` safetran
1997-10-13 0:00 ` FRS DES
1997-10-13 0:00 ` Jack Rudd
1997-10-14 0:00 ` Philip Brashear
1997-10-14 0:00 ` Gary L. Scott
1997-10-13 0:00 ` Gary L. Scott
[not found] ` <3442B745.5352@lmco.com>
1997-10-15 0:00 ` Gary L. Scott
1997-10-16 0:00 ` James Giles
1997-10-16 0:00 ` Andrew Haley
1997-10-13 0:00 ` David Ness
1997-10-14 0:00 ` Jan Karman
1997-10-15 0:00 ` Alan E & Carmel J Brain
1997-10-15 0:00 ` D'Arcy J.M. Cain
1997-10-15 0:00 ` Mark Stephen
1997-10-17 0:00 ` Randy MacDonald
1997-10-15 0:00 ` FRS DES
1997-10-16 0:00 ` Randy MacDonald
1997-10-16 0:00 ` Alan E & Carmel J Brain
1997-10-16 0:00 ` FRS DES
1997-10-17 0:00 ` Jerry van Dijk
1997-10-16 0:00 ` John Sullivan
1997-10-17 0:00 ` Alan E & Carmel J Brain
1997-10-17 0:00 ` John Sullivan
1997-10-17 0:00 ` Randy MacDonald
1997-10-17 0:00 ` Randy MacDonald
1997-10-20 0:00 ` Alan E & Carmel J Brain
1997-10-20 0:00 ` FRS DES
1997-10-21 0:00 ` Alan E & Carmel J Brain
1997-10-20 0:00 ` Lawrence Kirby
1997-10-20 0:00 ` Kaz
1997-10-21 0:00 ` Alan E & Carmel J Brain
1997-10-23 0:00 ` Ada Readability (Re: Programming language vote - results) Ray Blaak
1997-10-21 0:00 ` Programming language vote - results Alan E & Carmel J Brain
1997-10-21 0:00 ` Randy MacDonald
1997-10-22 0:00 ` Don Guinn
[not found] ` <01bce1bf$5c2baaa0$95b66bcf@dkelly.ark.com>
1997-10-29 0:00 ` FRS DES
1997-10-29 0:00 ` Don Guinn
1997-10-29 0:00 ` Shmuel (Seymour J.) Metz
1997-10-31 0:00 ` Documenting Code (was:Programming language vote - results) Alan E & Carmel J Brain
1997-10-30 0:00 ` Charles Lin
1997-10-30 0:00 ` James L. Ryan
1997-10-31 0:00 ` Robert Bernecky
1997-10-31 0:00 ` Robert Bernecky
1997-11-01 0:00 ` Randy MacDonald
1997-11-01 0:00 ` Robert Dewar
1997-11-03 0:00 ` Jon S Anthony
1997-10-29 0:00 ` Programming language vote - results Randy MacDonald
1997-10-25 0:00 ` Alan E & Carmel J Brain
1997-10-26 0:00 ` functionality of Java (was Re: Programming language vote - results) Randy MacDonald
1997-10-23 0:00 ` Programming language vote - results Jack Rudd
1997-10-25 0:00 ` Alan E & Carmel J Brain
1997-10-25 0:00 ` Kaz
1997-10-26 0:00 ` FRS DES
1997-10-27 0:00 ` Robert Bernecky
1997-10-27 0:00 ` APL argument W. Wesley Groleau x4923
1997-10-28 0:00 ` Randy MacDonald
1997-10-28 0:00 ` Programming language vote - results Jan Karman
1997-10-28 0:00 ` Robert Bernecky
1997-10-28 0:00 ` James L. Ryan
1997-10-29 0:00 ` Robert Bernecky
[not found] ` <bosworth-2910972044300001@access59.accsyst.com>
1997-10-30 0:00 ` Robert Bernecky
1997-10-30 0:00 ` James L. Ryan
1997-10-31 0:00 ` Robert Bernecky
1997-10-31 0:00 ` James L. Ryan
1997-10-29 0:00 ` Jack Rudd
1997-10-25 0:00 ` Peter Seebach
1997-11-18 0:00 ` Ingemar Ragnemalm
1997-11-18 0:00 ` firewind
1997-11-18 0:00 ` Larry Elmore
1997-11-20 0:00 ` firewind
1997-11-18 0:00 ` Kevin Swan
1997-11-19 0:00 ` Alan E & Carmel J Brain
1997-11-19 0:00 ` Mike Smith
1997-11-19 0:00 ` Matt
1997-11-20 0:00 ` firewind
[not found] ` <3474C71B.536B12F6@cgocable.net>
1997-11-21 0:00 ` CVigue
1997-11-23 0:00 ` Lawrence Kirby
1997-11-24 0:00 ` FRS DES
1997-11-20 0:00 ` Terry Richards
1997-11-20 0:00 ` Andy Knight
1997-11-23 0:00 ` Alex Krol
1997-11-25 0:00 ` William Tanksley
1997-11-26 0:00 ` Ron Natalie
1997-11-27 0:00 ` William Tanksley
1997-11-27 0:00 ` Lawrence Kirby [this message]
[not found] ` <65keij$mkd$1@nerd.apk.net>
1997-11-27 0:00 ` Kaz Kylheku
1997-11-28 0:00 ` Shmuel (Seymour J.) Metz
1997-12-01 0:00 ` FRS DES
1997-11-20 0:00 ` Andy Knight
1997-11-20 0:00 ` firewind
1997-11-20 0:00 ` Coding for Obscurity Alan E & Carmel J Brain
1997-11-20 0:00 ` Stephan Wilms
1997-11-21 0:00 ` Jos A. Horsmeier
1997-11-23 0:00 ` Alex Krol
1997-11-24 0:00 ` Jim Johnson
1997-11-24 0:00 ` Mark Wilden
1997-11-26 0:00 ` Robert S. White
1997-11-26 0:00 ` Leon Jones
1997-11-26 0:00 ` Lawrence Kirby
1997-11-26 0:00 ` Ron Natalie
1997-11-27 0:00 ` Joerg Rodemann
1997-11-26 0:00 ` Miguel Carrasquer Vidal
1997-12-01 0:00 ` ISONE
1997-12-01 0:00 ` ISONE
1997-11-26 0:00 ` Mark Wilden
1997-11-27 0:00 ` Richard A. O'Keefe
1997-11-23 0:00 ` Al Christians
1997-11-24 0:00 ` Richard A. O'Keefe
1997-11-24 0:00 ` Samuel T. Harris
1997-11-24 0:00 ` Jon S Anthony
1997-11-25 0:00 ` Samuel T. Harris
1997-11-24 0:00 ` Matt
1997-11-24 0:00 ` Ed Falis
1997-11-20 0:00 ` firewind
1997-11-20 0:00 ` Jos A. Horsmeier
1997-11-18 0:00 ` Programming language vote - results Kevin Swan
1997-11-29 0:00 ` Ingemar Ragnemalm
1998-09-10 0:00 ` Steven Katz
1997-11-18 0:00 ` Lawrence Kirby
1997-11-24 0:00 ` Martin M Dowie
1997-11-25 0:00 ` Kaz Kylheku
1997-11-26 0:00 ` Peter Seebach
1997-12-02 0:00 ` ANDREAS LEITNER
1997-12-02 0:00 ` Lawrence Kirby
1997-12-03 0:00 ` Billy Chambless
1997-12-03 0:00 ` Robert Dewar
1997-12-02 0:00 ` Robert Dewar
1997-12-05 0:00 ` John Sullivan
1997-11-25 0:00 ` Mark Wilden
1997-11-25 0:00 ` Martin M Dowie
1997-11-26 0:00 ` Lawrence Kirby
1997-11-26 0:00 ` FRS DES
1997-11-19 0:00 ` Alan E & Carmel J Brain
1997-11-19 0:00 ` Peter Seebach
[not found] ` <01bcdad2$fa9fdf60$25a43a91@basil.omroep.nl>
1997-10-17 0:00 ` D'Arcy J.M. Cain
1997-10-17 0:00 ` Robert I. Eachus
1997-10-14 0:00 ` Randy MacDonald
1997-10-13 0:00 ` Robert S. White
1997-10-13 0:00 ` Gary L. Scott
1997-10-13 0:00 ` Matthew Heaney
1997-10-14 0:00 ` Gary L. Scott
1997-10-19 0:00 ` William Rapp
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox