[Spice-devel] [RFC] codegen+demarshal: cast to void** through a temporary

Alexander Larsson alexl at redhat.com
Tue Aug 17 08:15:10 PDT 2010


On Thu, 2010-07-29 at 12:20 -0400, Alon Levy wrote:
> Changes
>  var = (void**)&val;
> Into
>  {
>   typeof val* p = &val;
>   var = (void**)p;
>  }
> 
> Which fixes these warnings (we compile with -Werror, any warning breaks compile):
>  warning: dereferencing type-punned pointer will break strict-aliasing rules

This is too ugly to live. I wonder why I don't get the warning with gcc
4.4.x though. Maybe its smarter?

Anyway, we could either do -Wno-strict-aliasing and assume we won't run
into actual problems from this, or we could try another workaround. The
C standard says that "char *" pointers may alias stuff, so maybe we can
get around things by casting via char *, or by storing the void ** as
char *.

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
       alexl at redhat.com            alexander.larsson at gmail.com 
He's a short-sighted neurotic firefighter fleeing from a secret government 
programme. She's a mistrustful insomniac vampire living on borrowed time. They 
fight crime! 



More information about the Spice-devel mailing list