missed uninitialised variable warning
Alexandre Oliva
aoliva@redhat.com
Mon Aug 4 18:33:00 GMT 2003
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
More information about the Gcc
mailing list