[FFmpeg-devel] misuse of gcc's __attribue__ align?

elupus elupus
Mon Jun 2 18:54:06 CEST 2008


Andrew Penner <ampenner <at> gmail.com> writes:

> 
> Hi, I was running into the "compiler didn't align stack variables"
> warning and came across a potential problem in the code...
> 
> The DECLARE_ALIGNED macro in libavcodec/mem.h is used in several
> places where local variables are being declared, particularly in
> ff_check_alignment function of libavcodec/dsputil.c. The only thing
> is, gcc does not obey the "attribute aligned" declaration for local
> variables.
> 
> When I compile with gcc 4.2 (as recommended) the warning goes away,
> but believe this is only a conincidence. According to the gcc manual
> (and a simple test program) using the aligned attribute on local
> variables is not supported.
> 
> So the questions is: does anyone care about this? This is problem for
> compilers which have a mechanism for aligment similar to the aligned
> attribute in gcc (i.e. doesn't work on local variables).
> 
> Am I missing something obvious? I'm trying to help make the code more
> friendly to other platforms, so please don't just say "use gcc >=
> 4.2".
> 
> Thanks,
> Andrew
> 

If you by local variables mean stack variables, then you are wrong. GCC 4.2 
does support that. It keeps it's stack pointer aligned on function entry, and 
due to that it works just fine. However if your stack isn't aligned when you 
enter gcc compiled code it won't work (unless you force gcc to realign 
pointer).

Where have you seen that this shouldn't be supported?







More information about the ffmpeg-devel mailing list