Topic: Interpretation Sought for DWP Concept of 'Valid Object


Author: "john (j.d.) hickin" <hickin@bnr.ca>
Date: 1996/04/12
Raw View
A recent thread in another newsgroup has aroused some interest.  Lately there
has been a small debate around the interpretation of the following phrase,
ostensibly taken from the DWP:

 A reference shall be initialized to refer to a valid object or function.

One party claims that valid object means initialized object while another
claims that all is required is that the object have a valid address.

Does the DWP make it clear which interpretation should be used?

--
John Hickin      Nortel Technology, Montreal, Quebec
(514) 765-7924   hickin@nortel.ca
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu
]





Author: fjh@mundook.cs.mu.OZ.AU (Fergus Henderson)
Date: 1996/04/12
Raw View
"john (j.d.) hickin" <hickin@bnr.ca> writes:

>A recent thread in another newsgroup has aroused some interest.  Lately there
>has been a small debate around the interpretation of the following phrase,
>ostensibly taken from the DWP:
>
> A reference shall be initialized to refer to a valid object or function.

The January 96 WP doesn't contain those words, or at least I couldn't spot
them.  It says instead

|   8.5.3  References                                       [dcl.init.ref]
|
| 1 A  variable  declared  to  be  a  T&,  that  is  "reference to type T"
|   (_dcl.ref_), shall be initialized by an object, or function, of type T
|   or by an object that can be converted into a T.  [Example:
|           int g(int);
|           void f()
|           {
|               int i;
|               int& r = i;  // `r' refers to `i'

This is straight out of ARM 8.4.3 (the only change is that "must" has
been replaced with "shall"), so it hasn't changed for a long time.

>One party claims that valid object means initialized object while another
>claims that all is required is that the object have a valid address.
>
>Does the DWP make it clear which interpretation should be used?

Yes: the latter interpretation is correct.  It is OK to initialize
a reference to refer to an uninitialized object, as in the example above.

--
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
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu
]





Author: vandevod@cs.rpi.edu (David Vandevoorde)
Date: 1996/04/15
Raw View
>>>>> "JH" == "john (j d ) hickin" <hickin@bnr.ca> writes:
[...]
JH> A recent thread in another newsgroup has aroused some interest.
JH> Lately there has been a small debate around the interpretation of
JH> the following phrase, ostensibly taken from the DWP:

JH>  A reference shall be initialized to refer to a valid object or
JH>     function.

I checked and could find no such wording. Instead, I found:

  [dcl.init.ref] 8.5.3/1
  A  variable  declared  to  be  a  T&,  that  is  "reference to type T"
  (_dcl.ref_), shall be initialized by an object, or function, of type T
  or by an object that can be converted into a T.

JH> One party claims that valid object means initialized object while
JH> another claims that all is required is that the object have a
JH> valid address.

JH> Does the DWP make it clear which interpretation should be used?

I'm not at all sure that the DWP uses the phrase `valid object' at
all. If it did, I would expect it to mean `an object whose lifetime
has begun and not expired'; the lifetime of an object is defined in
[basic.life].

 Daveed


[ 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: jpotter@falcon.lhup.edu (John E. Potter)
Date: 1996/04/17
Raw View
David Vandevoorde (vandevod@cs.rpi.edu) wrote:
: >>>>> "JH" == "john (j d ) hickin" <hickin@bnr.ca> writes:
: [...]
: JH> A recent thread in another newsgroup has aroused some interest.
: JH> Lately there has been a small debate around the interpretation of
: JH> the following phrase, ostensibly taken from the DWP:

: JH>  A reference shall be initialized to refer to a valid object or
: JH>     function.

: I checked and could find no such wording. Instead, I found:

:   [dcl.init.ref] 8.5.3/1
:   A  variable  declared  to  be  a  T&,  that  is
:   "reference to type T"
:   (_dcl.ref_), shall be initialized by an object, or function,
:   of type T
:   or by an object that can be converted into a T.

: JH> One party claims that valid object means initialized object while
: JH> another claims that all is required is that the object have a
: JH> valid address.

: JH> Does the DWP make it clear which interpretation should be used?

: I'm not at all sure that the DWP uses the phrase `valid object' at
: all. If it did, I would expect it to mean `an object whose lifetime
: has begun and not expired'; the lifetime of an object is defined in
: [basic.life].