This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: a warning to implement


Hi,
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.

nathan

-- 
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
           The voices in my head told me to say this
nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]