http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60124
Bug ID: 60124 Summary: g++ generates two copies of the same symbol due to __builtin_bswap32 return type Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mat at lcs dot mit.edu template<typename T> T identity(T x) { return x; } void fail() { identity(0U); identity(__builtin_bswap32(0)); } $ ~/gcc-4.8.2-install/bin/g++ -c ~/symbol_error.cpp -o ~/symbol_error.o /tmp/ccojWORv.s: Assembler messages: /tmp/ccojWORv.s:44: Error: symbol `_Z8identityIjET_S0_' is already defined It's as if g++ thinks the return type of __builtin_bswap32 is different for template interning, but the same for name mangling, so it produces bad assembly code with the same symbol used twice. This also fails with g++ 4.6.3 and 4.7.2. It works with clang 3.1 and 3.4.