Look at the following source code: #include <stdio.h>
typedef int __attribute__ ((aligned (16))) aint; inline void function() { static const aint x = 123; unsigned long a = (unsigned long) &x; printf("Address of x: 0x%lX - %s\n", a, a & 15L ? "ALIGNMENT ERROR" : "ok"); } int main() { function(); return 0; } The output on my system is: Address of x: 0x40E3E8 - ALIGNMENT ERROR The variable x is supposed to be aligned on a 16 byte boundary, but it is not. Note that this only happens when the function is inline and the variable is static. If I remove either "inline" or "static", the alignment seems to work properly. I am aware of bug #15795, but this is a different issue, since I'm not dynamically allocating memory here. Compiled like this: g++ tst.cpp -o tst Output of gcc -v: Using built-in specs. Target: i686-pc-cygwin Configured with: ../../source/gcc-4.1.1/configure --enable-threads=posix --enable-languages=c,c++ --disable-win32-registry Thread model: posix gcc version 4.1.1 I am using Cygwin on Windows 2000 Professional and Windows XP, and compiled GCC 4.1.1 from source using the configuration as specified above. -- Summary: Alignment error with static const variable in inline function Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jespdj at hotmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29249