🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #320

Re: null references & dereferencing null pointers

#320
From: Ron Guilmette
Date: Tue, 31 Jul 1990 22:15
62 lines
3077 bytes
In article <56159@microsoft.UUCP> jimad@microsoft.UUCP (Jim ADCOCK) writes:
>Proposed:
>
>1) That null references explicitly be defined as legal in the language.  A 
>null reference is that which is created from a "dereferenced" null pointer
>such as follows:
>
>	FOO& fooref = *((FOO*)0);
>
>2) That "dereferencing" null pointers except in the initialization of references
>be explicitly defined as not legal in the language.  The exact effect
>of dereferencing a null pointer would be "implementation defined", but the
>intent is that no legal object can be referenced via a null pointer.
>
>[disclaimer: this posting represents the opinions of an individual C++ user]

Jim,

It appears that you are going to be making a lot of proposals.  That's fine,
but if you want them taken seriously, you should try to come up with
some very specific wording that could be incorporated directly into the
ANSI draft document.  Also, you should try to specify what section of E&S
we are talking about for this proposal and you should say where and how
your new proposed text should be fitted together with the existing wording
in that section.

For instance:

	8.4.3 References

		Strike the first sentence and replace it with:

		"A variable declared to be a T&, that is `reference
		to type T' (&8.2.2), must be initialized by a value of
		type T&.  For the initializer of a reference, a conversion
		of a type T value to a type T& value will be implicitly
		supplied by the compiler where needed."

		"If the initializer for a reference is an expression
		whose last operation is the dereferencing of a pointer
		valued subexpression via the unary `*' operator, then the
		evaluation of the initializer expression will not include
		the application of the final unary `*'.  Rather, in such
		cases, the reference will be initialized to refer to the
		same portion of memory as does the pointer-valued sub-
		expression.  (Note that the value of the pointer-valued
		subexpression may legally be NULL.)"

		"Similarly, if the initializer for a reference is an
		expression which (before implicit conversions are applied)
		itself has the same reference type, then the evaluation of the
		initializer expression will not include the application of
		normal implicit conversion of that reference type value to its
		corresponding (referent) object type value.  Rather, the
		reference value itself will initialize the reference
		object which is being initialized."

-- 
// Ron Guilmette
// C++ Entomologist
// Internet: rfg@ncd.com      uucp: ...uunet!lupine!rfg
// Motto:  If it sticks, force it.  If it breaks, it needed replacing anyway.
Technical Details
Message-ID: <1028@lupine.NCD.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!wuarchive!uunet!lupine!rfg
References: <56159@microsoft.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!wuarchive!uunet!lupine!rfg
From: rfg@NCD.COM (Ron Guilmette)
Newsgroups: comp.std.c++
Subject: Re: null references & dereferencing null pointers
Message-ID: <1028@lupine.NCD.COM>
Date: 31 Jul 90 22:15:30 GMT
References: <56159@microsoft.UUCP>
Organization: Network Computing Devices, Inc., Mt. View, CA
Lines: 62