From -5646045910529402144
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,8366734ec6aad121
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1994-06-18 19:55:33 PST
Newsgroups: comp.std.c++
Path: nntp.gmd.de!Germany.EU.net!EU.net!howland.reston.ans.net!news.moneng.mei.com!uwm.edu!msuinfo!harbinger.cc.monash.edu.au!news.cs.su.oz.au!metro!news
From: maxtal@physics.su.OZ.AU (John Max Skaller)
Subject: Re: new foo[0]
Message-ID: <CrMHxy.FvD@ucc.su.OZ.AU>
Sender: news@ucc.su.OZ.AU
Nntp-Posting-Host: physics.su.oz.au
Organization: School of Physics, University of Sydney, Australia
References: <rfgCrKx5r.LMp@netcom.com> <9417005.12163@mulga.cs.mu.OZ.AU> <JASON.94Jun18150834@deneb.cygnus.com>
Date: Sun, 19 Jun 1994 02:37:10 GMT
Lines: 44

In article <JASON.94Jun18150834@deneb.cygnus.com> jason@cygnus.com (Jason Merrill) writes:

>> 	foo& r = myfoo0[0];
>
>Certainly such usage would yield undefined behavior, if 'r' were ever
>actually used for anything, and consequently an implementation can give a
>diagnostic for such code.  

	What do you mean by 'use'? 
Its a sadly abused term. In general for class types "use"
means "call a virtual member function virtually" or "select a data member
of scalar type in a context requiring loading a value" or
"enquire as to the Run Time Type" (and a few other things
like conversions of pointers to virtual bases).

	Everything else is just address calculations not
requiring access to the object.

	Even calling a non-virtual member is just address
calculations: only virtual function calls actually
require an object to exist. Address calculations should be
legal if, and only if, they compute valid addresses:
binding a reference may be thought of as the same as
initialising a pointer.

	Thus above, computing the address of a non-static
member by say:

	r.mem

is invalid (its "more" than one past the end of the array :-)
But forming the reference 'r' is not.

Such an address calculation is perfect fine, however
even if the object does not exist, provided the underlying
memory does -- ONLY attempts to read memory should yield
undefined behaviour (including use of virtual bases
or functions and reading the value of a scalar member subobject.)

--
        JOHN (MAX) SKALLER,         INTERNET:maxtal@suphys.physics.su.oz.au
	Maxtal Pty Ltd,		    CSERVE:10236.1703 
        6 MacKay St ASHFIELD,	    Mem: SA IT/9/22,SC22/WG21 
        NSW 2131, AUSTRALIA	    


