[FFmpeg-devel] Hacks on FATE

matthieu castet castet.matthieu
Thu Jun 18 21:20:08 CEST 2009


M?ns Rullg?rd <mans <at> mansr.com> writes:

> Those are wrong then.  Think about it for a moment.  A memory operand
> is nothing but a region of memory *with a specific type*.  A *value*
> can be converted to another type (implicitly or by a cast), but a
> value *as stored* has a fixed type that cannot be altered.
> 
> Using cast expressions with the 'm' constraint is as wrong as code
> like this:
> 
>   void foo(int *);
>   char x;
>   foo((int*)&x);
> 
> That gcc, perhaps by accident, allows such nonsense is no excuse for
> writing code that way.
The worst of this is that it work if gcc only if the cast does nothing :


$ cat /tmp/pp.c
int foo()
{
        int a;
        asm("nop"
                        :
                        : "m"((long)(a))
                        );
}

$ gcc -m64  /tmp/pp.c -c -o /tmp/p.o
/tmp/pp.c: In function 'foo':
/tmp/pp.c:4: error: memory input 0 is not directly addressable







More information about the ffmpeg-devel mailing list