[MPlayer-dev-eng] [PATCH] -fno-strict-aliasing on gcc > 3

Joerg Sonnenberger joerg at britannica.bec.de
Wed Jul 13 22:28:21 CEST 2005


On Wed, Jul 13, 2005 at 09:48:57PM +0200, Michael Niedermayer wrote:
> well, id say add -fno-strict-aliasing to the files which need it but leave the 
> rest for now
> the real problem is again that gcc is crap, it is too silly to figure out 
> which pointers clearly cant alias each other (so that -fno-strict-aliasing 
> would be fast enough) and OTOH its to silly to realize that a x= (float*)y 
> means that both alias each other so either way sucks, the programmer has to 
> do what the compiler should do

Actually, C is one of the very few languages which didn't *specify* the
behaviour until very recently (ISO C99). For example, Fortran always had
a rule of different types -- can't alias. There are a lot of very bad hacks
which have been used before and which are the reason why char * is still
allowed to alias anything.

No, this doesn't mean a programmer has to do something the compiler could
do. The programmer is clearly hacking around the supposed situation here.
If you really want to read a float value as something else from the same
address, use char *. That's allowed and often (e.g. on strict alignment
architectures) needed anyway.

Joerg




More information about the MPlayer-dev-eng mailing list