Topic: Question about 4.1


Author: "Anthony Williams" <anthwil@nortelnetworks.com>
Date: Fri, 27 Jul 2001 09:32:46 GMT
Raw View
"none" <none@noreply.com> wrote in message
news:JzW77.83$UH6.191399@news02.optonline.net...
>
> "Anthony Williams" <anthwil@nortelnetworks.com> wrote in message
> news:9jm5q3$ai3$1@ID-49767.news.dfncis.de...
> > "none" <none@noreply.com> wrote in message
> > news:AWf77.137890$qs5.21135129@news02.optonline.net...
> > > 4.1 /1 Lvalue-to-rvalue conversion
> > >
> > >   An lvalue (3.10) of a non-function, non-array type T can be
converted
> to
> > > an rvalue.
> > >   If T is an incomplete type, a program that necessitates this
> conversion
> > is
> > > ill-formed.
> > >   If the object to which the lvalue refers is not an object of type T
> and
> > is
> > > not an
> > >   object of a type derived from T, or if the object is uninitialized,
a
> > > program that
> > >   necessitates this conversion has undefined behavior.
> > >
> > > is the use of uninitialized too strong here
> > >
> > > if taken literally does it suggest the following program is undefined
> > >
> > > void foo(int)
> > > {
> > > }
> > >
> > > int main()
> > > {
> > >   int i;
> > >   i = 0
> > >   foo(i);
> > > }
> >
> > At what point is an uninitialized lvalue converted to an rvalue?
>
> foo(i); // lvalue to rvalue conversion on i
>
> At what point is i initialized ?

i=0;

Anthony
--
Anthony Williams
Software Engineer, Nortel Networks Optoelectronics
The opinions expressed in this message are not necessarily those of my
employer



---
[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: "James Russell Kuyper Jr." <kuyper@wizard.net>
Date: Fri, 27 Jul 2001 17:02:54 GMT
Raw View
none wrote:
>
> "Anthony Williams" <anthwil@nortelnetworks.com> wrote in message
> news:9jm5q3$ai3$1@ID-49767.news.dfncis.de...
> > "none" <none@noreply.com> wrote in message
> > news:AWf77.137890$qs5.21135129@news02.optonline.net...
> > > 4.1 /1 Lvalue-to-rvalue conversion
> > >
> > >   An lvalue (3.10) of a non-function, non-array type T can be converted
> to
> > > an rvalue.
> > >   If T is an incomplete type, a program that necessitates this
> conversion
> > is
> > > ill-formed.
> > >   If the object to which the lvalue refers is not an object of type T
> and
> > is
> > > not an
> > >   object of a type derived from T, or if the object is uninitialized, a
> > > program that
> > >   necessitates this conversion has undefined behavior.
> > >
> > > is the use of uninitialized too strong here
> > >
> > > if taken literally does it suggest the following program is undefined
> > >
> > > void foo(int)
> > > {
> > > }
> > >
> > > int main()
> > > {
> > >   int i;
> > >   i = 0
> > >   foo(i);
> > > }
> >
> > At what point is an uninitialized lvalue converted to an rvalue?
>
> foo(i); // lvalue to rvalue conversion on i
>
> At what point is i initialized ?

The standard does not define initialization, per se. It defines copy
initialization, and direct initialization, but it doesn't say that those
are the only two forms of initialization. It even has an entire section
devoted to initialization, yet fails to define it. In conventional use,
initialization occurs when an object initially acquires a value, whether
or not that value is acquired at the point of declaration, or by a later
assignment operator. That definition seems consistent with every use of
the term that I could find in the standard.

Therefore, the point of initialization of 'i' is the "i=0;" statement.
If this were not the intended meaning "initialized" for the purposes of
4.1, there would be an awful lot ill-formed code out there. I'll agree,
this could be clearer.

---
[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: none <none@noreply.com>
Date: Fri, 27 Jul 2001 18:11:48 GMT
Raw View
"Anthony Williams" <anthwil@nortelnetworks.com> wrote in message
news:9jr88b$176uk$1@ID-49767.news.dfncis.de...
>
> "none" <none@noreply.com> wrote in message
> news:JzW77.83$UH6.191399@news02.optonline.net...
> >
> > "Anthony Williams" <anthwil@nortelnetworks.com> wrote in message
> > news:9jm5q3$ai3$1@ID-49767.news.dfncis.de...
> > > "none" <none@noreply.com> wrote in message
> > > news:AWf77.137890$qs5.21135129@news02.optonline.net...
> > > > 4.1 /1 Lvalue-to-rvalue conversion
> > > >
> > > >   An lvalue (3.10) of a non-function, non-array type T can be
> converted
> > to
> > > > an rvalue.
> > > >   If T is an incomplete type, a program that necessitates this
> > conversion
> > > is
> > > > ill-formed.
> > > >   If the object to which the lvalue refers is not an object of type
T
> > and
> > > is
> > > > not an
> > > >   object of a type derived from T, or if the object is
uninitialized,
> a
> > > > program that
> > > >   necessitates this conversion has undefined behavior.
> > > >
> > > > is the use of uninitialized too strong here
> > > >
> > > > if taken literally does it suggest the following program is
undefined
> > > >
> > > > void foo(int)
> > > > {
> > > > }
> > > >
> > > > int main()
> > > > {
> > > >   int i;
> > > >   i = 0
> > > >   foo(i);
> > > > }
> > >
> > > At what point is an uninitialized lvalue converted to an rvalue?
> >
> > foo(i); // lvalue to rvalue conversion on i
> >
> > At what point is i initialized ?
>
> i=0;
>

That is what has confused me, because every use of the term
initialized within the standard seems to refer to initializations
and not assignments. Is there wording in the standard that says
that after assignment, variables are considered initialized ?

---
[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: "Anthony Williams" <anthwil@nortelnetworks.com>
Date: Wed, 25 Jul 2001 21:05:15 GMT
Raw View
"none" <none@noreply.com> wrote in message
news:AWf77.137890$qs5.21135129@news02.optonline.net...
> 4.1 /1 Lvalue-to-rvalue conversion
>
>   An lvalue (3.10) of a non-function, non-array type T can be converted to
> an rvalue.
>   If T is an incomplete type, a program that necessitates this conversion
is
> ill-formed.
>   If the object to which the lvalue refers is not an object of type T and
is
> not an
>   object of a type derived from T, or if the object is uninitialized, a
> program that
>   necessitates this conversion has undefined behavior.
>
> is the use of uninitialized too strong here
>
> if taken literally does it suggest the following program is undefined
>
> void foo(int)
> {
> }
>
> int main()
> {
>   int i;
>   i = 0
>   foo(i);
> }

At what point is an uninitialized lvalue converted to an rvalue?

Anthony
--
Anthony Williams
Software Engineer, Nortel Networks Optoelectronics
The opinions expressed in this message are not necessarily those of my
employer



---
[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: none <none@noreply.com>
Date: Thu, 26 Jul 2001 16:27:58 GMT
Raw View
"Anthony Williams" <anthwil@nortelnetworks.com> wrote in message
news:9jm5q3$ai3$1@ID-49767.news.dfncis.de...
> "none" <none@noreply.com> wrote in message
> news:AWf77.137890$qs5.21135129@news02.optonline.net...
> > 4.1 /1 Lvalue-to-rvalue conversion
> >
> >   An lvalue (3.10) of a non-function, non-array type T can be converted
to
> > an rvalue.
> >   If T is an incomplete type, a program that necessitates this
conversion
> is
> > ill-formed.
> >   If the object to which the lvalue refers is not an object of type T
and
> is
> > not an
> >   object of a type derived from T, or if the object is uninitialized, a
> > program that
> >   necessitates this conversion has undefined behavior.
> >
> > is the use of uninitialized too strong here
> >
> > if taken literally does it suggest the following program is undefined
> >
> > void foo(int)
> > {
> > }
> >
> > int main()
> > {
> >   int i;
> >   i = 0
> >   foo(i);
> > }
>
> At what point is an uninitialized lvalue converted to an rvalue?

foo(i); // lvalue to rvalue conversion on i

At what point is i initialized ?

---
[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: none <none@noreply.com>
Date: Tue, 24 Jul 2001 17:01:03 GMT
Raw View
4.1 /1 Lvalue-to-rvalue conversion

  An lvalue (3.10) of a non-function, non-array type T can be converted to
an rvalue.
  If T is an incomplete type, a program that necessitates this conversion is
ill-formed.
  If the object to which the lvalue refers is not an object of type T and is
not an
  object of a type derived from T, or if the object is uninitialized, a
program that
  necessitates this conversion has undefined behavior.

is the use of uninitialized too strong here

if taken literally does it suggest the following program is undefined

void foo(int)
{
}

int main()
{
  int i;
  i = 0
  foo(i);
}

---
[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]