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: missed uninitialised variable warning


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


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