Consider the following sample: #include <cstdio>
struct C { int a,b,c,d,e; C() { printf("&e = %p\n", &e); e = 12345; } }; int main() { unsigned long long a[] = {1, 2}; printf("a = %p, a[0] = %lld\n", a, a[0]); { C s; } printf("a = %p, a[0] = %lld\n", a, a[0]); unsigned long long b[] = {3, 4}; return 0; } Compiling with `g++ sample.cpp` yields the following output: a = 0xbfdb7920, a[0] = 1 &e = 0xbfdb7920 a = 0xbfdb7920, a[0] = 12345 whereas compiling with `g++ -fno-stack-protector sample.cpp` yields: a = 0xbfc1cf90, a[0] = 1 &e = 0xbfc1cf80 a = 0xbfc1cf90, a[0] = 1 I don't have time to go into more detail but the sample should be small enough to figure the problem out. # gcc -v Reading specs from /usr/lib/gcc/i686-pc-linux-gnu/3.4.6/specs Configured with: /var/tmp/portage/sys-devel/gcc-3.4.6-r2/work/gcc-3.4.6/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.4.6 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/3.4.6/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.4.6 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.4.6/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.4.6/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/3.4.6/include/g++-v3 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --disable-multilib --disable-libgcj --with-arch=i686 --enable-languages=c,c++,treelang,f77 --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu Thread model: posix gcc version 3.4.6 (Gentoo Hardened 3.4.6-r2 p1.6, ssp-3.4.6-1.0, pie-8.7.10) -- Summary: g++-3.4.6 (ssp) stack layout problem involving scopes Product: gcc Version: 3.4.6 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: thomasheinz at gmx dot net GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42887