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: dewar at gnat dot com (Robert Dewar)
- Cc: akpm at osdl dot org, gcc at gcc dot gnu dot org, gdr at integrable-solutions dot net, guerby at acm dot org, matz at suse dot de, pinskia at physics dot uc dot edu
- Date: 04 Aug 2003 15:29:56 -0300
- Subject: Re: missed uninitialised variable warning
- Organization: GCC Team, Red Hat
- References: <20030804182102.23AD2F2D7C@nile.gnat.com>
On Aug 4, 2003, dewar@gnat.com (Robert Dewar) wrote:
>> void *x = &x;
>>
>> This must work, and I don't see anything possibly dubious about it.
> but I am not sure I can deduce that this must always work from the
> formal semantics
I don't see anything odd about a generic pointer pointing to a memory
location that happens to be its own address. If you cast this void*
back to its original type (void**), you can even assign to it:
*(void**)x = some_other_pointer;
and it's required to work correctly, i.e., to assign this other
pointer to x.
Now let's please not talk about whether this is actually useful :-)
It may even turn out to be (circular linked lists come to mind), but I
probably wouldn't recommend this style anyway :-)
--
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