Created attachment 30334 [details] sample code The attached sample produces incorrect values with 32-bit. The function, that produces the incorrect values is part of FLAC 1.2.1. I first ran into the behavior with the 32-bit version of GCC 4.6.3 by MinGW-w64 and was able to confirm it with a -m32 cross-compile of GCC 4.7.3 bundled with ubuntu 13.04. The expected result appears to be the 64-bit one since it matches the values produced by Visual Studio 2012 32-bit and 64-bit as well as clang 3.3 on ubuntu 13.04. The expected result is: 6945.132324 4500.032715 1060.377319 -132.546219 95.539162 216.320663 80.951294 -48.548409 -61.090591 36.541431 273.282440 315.549683 100.133156 -48.032295 72.734283 223.127853 The incorrect result is: 6945.131836 4500.032715 1060.377319 -132.546204 95.539146 216.320633 80.951294 -48.548393 -61.090607 36.541412 273.282410 315.549683 100.133156 -48.032322 72.734268 223.127853 The information about the Mmingw-w64 compile in question: Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=c:/mingw/mingw64-w32/bin/../libexec/gcc/i686-w64-mingw32/4.6.3/lto-wrapper.exe Target: i686-w64-mingw32 Configured with: /home/ruben/mingw-w64/src/gcc/configure --host=i686-w64-mingw32 --build=x86_64-linux-gnu --target=i686-w64-mingw32 --with-sysroot=/home/ruben/mingw-w64/mingw32mingw32/mingw32 --prefix=/home/ruben/mingw-w64/mingw32mingw32/mingw32 --with-gmp=/home/ruben/mingw-w64/prereq/i686-w64-mingw32/install --with-mpfr=/home/ruben/mingw-w64/prereq/i686-w64-mingw32/install --with-mpc=/home/ruben/mingw-w64/prereq/i686-w64-mingw32/install --with-ppl=/home/ruben/mingw-w64/prereq/i686-w64-mingw32/install --with-cloog=/home/ruben/mingw-w64/prereq/i686-w64-mingw32/install --enable-cloog-backend=isl --with-host-libstdcxx='-static -lstdc++ -lm' --enable-shared --enable-static --enable-threads=win32 --enable-plugins --disable-multilib --enable-languages=c,lto,c++,objc,obj-c++,fortran,java --enable-libgomp --disable-dw2-exceptions --enable-sjlj-exceptions --enable-fully-dynamic-string --enable-libstdcxx-time --disable-nls --disable-werror --enable-checking=release --with-gnu-as --with-gnu-ld --disable-win32-registry --disable-rpath --disable-werror --with-libiconv-prefix=/home/ruben/mingw-w64/prereq/i686-w64-mingw32/install CFLAGS='-O2 -march=nocona -mtune=core2 -fomit-frame-pointer -momit-leaf-frame-pointer -fgraphite-identity -floop-interchange -floop-block -floop-parallelize-all' LDFLAGS= : (reconfigured) /home/ruben/mingw-w64/src/gcc/configure --host=i686-w64-mingw32 --build=x86_64-linux-gnu --target=i686-w64-mingw32 --with-sysroot=/home/ruben/mingw-w64/mingw32mingw32/mingw32 --prefix=/home/ruben/mingw-w64/mingw32mingw32/mingw32 --with-gmp=/home/ruben/mingw-w64/prereq/i686-w64-mingw32/install --with-mpfr=/home/ruben/mingw-w64/prereq/i686-w64-mingw32/install --with-mpc=/home/ruben/mingw-w64/prereq/i686-w64-mingw32/install --with-ppl=/home/ruben/mingw-w64/prereq/i686-w64-mingw32/install --with-cloog=/home/ruben/mingw-w64/prereq/i686-w64-mingw32/install --enable-cloog-backend=isl --with-host-libstdcxx='-static -lstdc++ -lm' --enable-shared --enable-static --enable-threads=win32 --enable-plugins --disable-multilib --enable-libgomp --disable-dw2-exceptions --enable-sjlj-exceptions --enable-fully-dynamic-string --enable-libstdcxx-time --disable-nls --enable-checking=release --with-gnu-as --with-gnu-ld --disable-win32-registry --disable-rpath --disable-werror --with-libiconv-prefix=/home/ruben/mingw-w64/prereq/i686-w64-mingw32/install CFLAGS='-O2 -march=nocona -mtune=core2 -fomit-frame-pointer -momit-leaf-frame-pointer -fgraphite-identity -floop-interchange -floop-block -floop-parallelize-all' LDFLAGS= build_alias=x86_64-linux-gnu host_alias=i686-w64-mingw32 target_alias=i686-w64-mingw32 --enable-languages=c,c++,fortran,java,lto,objc,obj-c++ --no-create --no-recursion Thread model: win32 gcc version 4.6.3 (GCC) The information about the version used on ubuntu: Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.7.3-1ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --with-system-zlib --enable-objc-gc --with-cloog --enable-cloog-backend=ppl --disable-cloog-version-check --disable-ppl-version-check --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-1ubuntu1)
looks like expected behavior to me, please read: http://gcc.gnu.org/wiki/x87note you may be able to get consistent results by using -mfpmath=sse e.g. clang will always use amd64 mode even on 32 bit, thus probably the same result.
This sounds like bug 323.
It's unoptimized code and using -msse -mfpmath=sse fixes it. But there is another fix: http://msdn.microsoft.com/en-us/library/vstudio/7t5yh4fd(v=vs.110).aspx Changing autoc[coeff] += d * data[sample+coeff]; to FLAC__real tmp = d * data[sample+coeff]; autoc[coeff] += tmp; also provides the same results with 32-bit as 64-bit does.
Dup. *** This bug has been marked as a duplicate of bug 323 ***