This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: missed uninitialised variable warning
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Cc: dewar at gnat dot com (Robert Dewar), guerby at acm dot org, akpm at osdl dot org, gcc at gcc dot gnu dot org, matz at suse dot de, pinskia at physics dot uc dot edu
- Date: 04 Aug 2003 15:21:24 -0300
- Subject: Re: missed uninitialised variable warning
- Organization: GCC Team, Red Hat
- References: <20030804180850.8095AF2D7C@nile.gnat.com><m33cghmgrx.fsf@uniton.integrable-solutions.net>
On Aug 4, 2003, Gabriel Dos Reis <gdr@integrable-solutions.net> wrote:
> unsigned char c = c;
Actually, I *think* this invokes undefined behavior, because you use
an uninitialized value. This is quite different from:
> void* x = &x;
that is indeed guaranteed to work. The difference is clearly that you
use the former as an rvalue, and the latter as an lvalue.
Even more interesting is:
int &x = x;
this is not illegal, but it's obviously useless, as any use of x would
invoke undefined behavior, even if the initialization (contrary to my
believe) doesn't.
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist Professional serial bug killer