Passing __builtin_bswap32 or __builtin_bswap64 (or assumedly any builtin function) as an argument to a template will cause that function to be emitted twice in the generated assembly.
See the following example. (which could probably be even further simplified if needed). Attached is a .cpp/.ii/.s set for this error as well as a simple workaround which merely wraps the built in functions with an inline function which just calls the built in. compiling with any (or no) arguments / defines it does not matter.
Note that I've seen similar issues / questions in regards to warnings from printf format strings giving warnings for "format '%u' expects type 'unsigned int', but argument 2 has type 'unsigned int'". This is likely related, but not necessarily. If desired it can be reproduced with a simple "printf("%u", __builtin_bswap32(0x78563412UL) );"
template<typename expectedType, typename actualType>
inline void CompareHelper_EQ(expectedType , actualType )
int main ()
// One duplicate:
CompareHelper_EQ(static_cast<uint32_t>(0x12345678UL), (static_cast<uint32_t>(0x12345678UL)) );
// Another duplicate
Running Windows 7 x64. Issue occurs building win32 or win64 programs. I have tested as far back as mingw G++ version 4.3.2 and the issue is still there. The issue does not occur when building in OSX (using GCC 4.2 or 4.0).
g++ 4.5.0 -v output for reference:
Using built-in specs.
Configured with: ../../gcc-4.5.0/configure --prefix=/mingw --build=mingw32 --enable-languages=c,ada,c++,fortran,objc,obj-c++ --disable-nls --disable-win32-regis
try --enable-libgomp --disable-werror --enable-threads --disable-symvers --enable-cxx-flags='-fno-function-sections -fno-data-sections' --enable-fully-dynamic-s
tring --enable-libstdcxx-debug --enable-version-specific-runtime-libs --with-pkgversion=tdm-1 --enable-sjlj-exceptions --with-bugurl=http://tdm-gcc.tdragon.net/
Thread model: win32
gcc version 4.5.0 (tdm-1)
Log in to post a comment.