When using very heavily templated code and _FORTIFY_SOURCE, gcc-4.3.3 may generate buggy code: Specifically from "/usr/include/bits/string3.h" __extern_always_inline void * __NTH (memset (void *__dest, int __ch, size_t __len)) { if (__builtin_constant_p (__len) && __len == 0) { __warn_memset_zero_len (); return __dest; } return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest)); } the last line is compiled to: Dump of assembler code for function memset: 0x0000000000439860 <memset+0>: jmp 0x439860 <memset> End of assembler dump. Reproducible: Always Steps to Reproduce: Unfortunately, I don't have a small one-file test case because the buggy code is called during the initialization phase of the program, calling global constructors. All I know so far is, that using boost::mpl::vector and BOOST_AUTO_TEST_CASE_TEMPLATE triggers the bug somehow, but not always, i.e. my first try to create a test case resulted in good code, but it may also be that it just didn't call memset during initialization. Actual Results: Endless loop in memset Expected Results: code that does what it should. The problem is not Gentoo nor x86_64 specific, I also hit it when I compile the code on Ubuntu with the same compiler version and on x86 too. It can be avoided by compiling with -D_FORTIFY_SOURCE=0 I have tried to isolate a test case but so far to no avail. The project that triggers the bug is available at https://mia.svn.sourceforge.net/svnroot/mia/mia2/ but if someone has a lot of time and really want to dig into it then we should probably communicate privately.
This looks like a non-bug. mia/core/defines.hh defines __attribute__ to be ignored if __GCC__ is not defined. (GCC does not define __GCC__ itself.) When __attribute__ is redefined, standard headers don't work as expected; the inline definition of memset is just one thing that breaks.
Indeed, checking for __GNUC__ instead of __GCC__ made the problem go away. Thanks for digging through the code. In addition, I tested g++-4.4 and there the issue didn't show up at all.