bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Warnings when compiling the Hurd -- strict aliasing


From: Samuel Thibault
Subject: Re: Warnings when compiling the Hurd -- strict aliasing
Date: Thu, 14 Jun 2007 17:21:58 +0200
User-agent: Mutt/1.5.11

Answering to myself.

Samuel Thibault, le Thu 14 Jun 2007 16:57:29 +0200, a écrit :
> Thomas Schwinge, le Thu 14 Jun 2007 16:42:10 +0200, a écrit :
> > From the quick glance I had, the problem is that MIG only handles data
> > structures via the `vm_address_t' type, whereas in the C code those
> > are pointers to structures.
> 
> But if I understand correctly, the problem is that doing this:
> 
> > +typedef    vm_offset_t __attribute__ ((__may_alias__))     vm_address_t;
> 
> will make vm_offset_t alias anybody, but not the content it is referring
> to.

Actually, I asked a guy that really knows such things, and the content
itself is not a problem: casting its address into an integer and giving
it somewhere else forces the compiler to assume it will be dereferenced
there.

Now, making vm_address_t alias everybody will probably make the warning
and potential bugs disappear, but it will restrict optimizations in
other places for instance, while writing

        void *new_buf = old_buf + old_buf_len; /* First try.  */
        vm_address_t _new_buf = (vm_address_t) new_buf;

        zerr = vm_allocate (mach_task_self (),
                &_new_buf, new_buf_len - old_buf_len,
                0);

        new_buf = (void *) _new_buf;

is maybe a bit more verbose, but is correct.

Samuel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]