[linux-dvb] [patch 3/3] fix strict aliasing warning.

Ludwig Nussel ludwig.nussel at suse.de
Thu Sep 29 14:45:13 CEST 2005


Johannes Stezenbach wrote:
> On Thu, Sep 29, 2005 Ludwig Nussel wrote:
> > An int* must not be used to change some enum. As workaround a char* can be
> > used.
> 
> Says who?

My local gcc guru ;-) As far as I understood gcc makes the
assumption that a pointer to e.g. int never points to a float, enum
something etc and vice versa. With that assumption it can optimize
some cases better but may also produces garbage if your pointers do
point to the same location. Only char* may point to anything.

> Which compiler with whcih option gives you a warning about this?

gcc (GCC) 4.1.0 20050920 (experimental) (SUSE Linux)

-O2 -Wall -D_FORTIFY_SOURCE=2

> This patch looks wrong to me.

This whole alising stuff is strange. The code as it is right now is
definitively wrong, eventhough gcc probably doesn't produce garbage
in this case as the affected function likely will not be inlined.
Anyways, aliasing isn't exactly something I care about but I can't
get packages out of our build system as long as there are such
problems. if you think the interface to parse_param is perfect
-fno-strict-aliasing needs to be added to CFLAGS.

cu
Ludwig

-- 
 (o_   Ludwig Nussel
 //\   SUSE LINUX Products GmbH, Development
 V_/_  http://www.suse.de/



More information about the linux-dvb mailing list