Topic: Unitialized dynamic reference
Author: daniel@cse.ucsc.edu (Daniel R. Edelson)
Date: 7 Nov 1992 17:29:59 GMT Raw View
In article <1992Nov7.160634.1@vax1.bham.ac.uk> mccauleyba@vax1.bham.ac.uk (Brian McCauley) writes:
>In article <1dessbINNn1b@darkstar.UCSC.EDU>, daniel@cse.ucsc.edu (Daniel R. Edelson) writes:
>> ... is the following illegal?
>>
>> new (int&)
>Yes the type of this expression is `int&*'. There is no such type!
>(Because if you try to take the address of reference what you get is the
>address of the thing referred to.)
This could conceivably be interpreted as returning the
address of the referent (just like taking the address
of a reference), though I don't think that's a
correct interpretation. My point is if this is clearly
illegal, some explicit mention should perhaps be made
in the draft standard.
Daniel Edelson
Author: mccauleyba@vax1.bham.ac.uk (Brian McCauley)
Date: 7 Nov 92 16:06:34 GMT Raw View
In article <1dessbINNn1b@darkstar.UCSC.EDU>, daniel@cse.ucsc.edu (Daniel R. Edelson) writes:
> ... is the following illegal?
>
> new (int&)
Yes the type of this expression is `int&*'. There is no such type!
(Because if you try to take the address of reference what you get is the
address of the thing referred to.)
> All the compilers I tried permitted it.
Get some better compilers - Borland 3.1 spotted the error.
\\ ( ) NO BULLSHIT! from BAM (Brian McCauley)
. _\\__[oo ============
.__/ \\ /\@
. l___\\ E-mail: B.A.McCauley@bham.ac.uk
# ll l\\
###LL LL\\
Author: daniel@cse.ucsc.edu (Daniel R. Edelson)
Date: 6 Nov 92 22:50:51 GMT Raw View
The draft standard has the following to say about references:
``The declaraion of a reference must contain an initializer except
when the declaration contains an explicit extern specifier, is a
class member, declaration within a class declaration, or is the
declaration of an argument or return type.''
So, given that, is the following illegal?
new (int&)
All the compilers I tried permitted it.
Thanks,
Daniel Edelson
Author: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
Date: Tue, 10 Nov 1992 01:31:15 GMT Raw View
In article <1dessbINNn1b@darkstar.UCSC.EDU> daniel@cse.ucsc.edu (Daniel R. Edelson) writes:
>
>The draft standard has the following to say about references:
>
>``The declaraion of a reference must contain an initializer except
>when the declaration contains an explicit extern specifier, is a
>class member, declaration within a class declaration, or is the
>declaration of an argument or return type.''
>
>So, given that, is the following illegal?
>
> new (int&)
>
>All the compilers I tried permitted it.
>
Wow, wonder what they allocated? IMHO: It does not make sense
to allocate a reference, only an object.
--
;----------------------------------------------------------------------
JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------