This is the mail archive of the
mailing list for the GCC project.
Re: a warning to implement
- From: Nathan Sidwell <nathan at acm dot org>
- To: Robert Dewar <dewar at gnat dot com>
- Cc: gdr at codesourcery dot com, rsandifo at redhat dot com, gcc at gcc dot gnu dot org
- Date: Wed, 06 Feb 2002 16:29:20 +0000
- Subject: Re: a warning to implement
- References: <20020206160258.479A3F28CF@nile.gnat.com>
- Reply-to: nathan at compsci dot bristol dot ac dot uk
I've been reading this thread, and I still can't figure out how
T x = x;
as anything but undefined semantics. I'm talking C++ here.
[3.3.1]/1 gives an example about point of declaration, and says of
int x = x;
Here ... is initialized with its own (indeterminate) value.
But, that assignment requires an lvalue to rvalue conversion on 'x',
and [4.1] says
'or if the object is uninitialized,... undefined behaviour'
So it appears that we've got undefined behaviour for any POD T.
For a class T, we could be calling the copy ctor T(T const &).
Reference binding at [8.3.1]/4 says a reference must be bound to a
`valid object'. I suppose that it is ok to reference bind to an
object of indeterminate value.
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
The voices in my head told me to say this
email@example.com http://www.cs.bris.ac.uk/~nathan/ firstname.lastname@example.org