Fix aliasing warning
Marcus Meissner
meissner@suse.de
Tue Jun 28 07:45:00 GMT 2005
On Tue, Jun 28, 2005 at 08:42:49AM +0100, Andrew Haley wrote:
> Marcus Meissner writes:
> > > This is unfortunate, and does expose aliasing issues. Luckily I think the
> > > aliasing won't bite as we don't read through one then write through the
> > > other within the same compiler visible code.
> >
> > > ! sc = (struct sigcontext *) &rt_->uc.uc_mcontext;
> > .....
> > > ! /* The void * cast is necessary to avoid an aliasing warning.
> > > ! The aliasing warning is correct, but should not be a problem
> > > ! because it does not alias anything. */
> > > ! sc = (struct sigcontext *) (void *)&rt_->uc.uc_mcontext;
> >
> > Hmm, as far as I know this does not fix the bug, it just hides
> > the warning?
> >
> > At least thats what I got told as I added (char*) casts to similar code.
>
> Surely the comment explains this perfectly well -- the value isn't
> accessed anywhere else in the program by another type. The type as
> declared in the system header is wrong, so we have to cast it.
>
> What else could we do? Volatile, perhaps? Some kind of union?
I forgot to study the comment closer ... sorry.
Ciao, Marcus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20050628/36f78375/attachment.sig>
More information about the Gcc-patches
mailing list