missed uninitialised variable warning

Alexandre Oliva aoliva@redhat.com
Mon Aug 4 18:28:00 GMT 2003


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



More information about the Gcc mailing list