public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/57669] New: Incorrect floating point values with 32-bit compile
@ 2013-06-21 12:33 oliverst at online dot de
  2013-06-21 15:50 ` [Bug c/57669] " jtaylor.debian at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: oliverst at online dot de @ 2013-06-21 12:33 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57669

            Bug ID: 57669
           Summary: Incorrect floating point values with 32-bit compile
           Product: gcc
           Version: 4.7.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: oliverst at online dot de

Created attachment 30334
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30334&action=edit
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)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c/57669] Incorrect floating point values with 32-bit compile
  2013-06-21 12:33 [Bug c/57669] New: Incorrect floating point values with 32-bit compile oliverst at online dot de
@ 2013-06-21 15:50 ` jtaylor.debian at gmail dot com
  2013-06-21 16:27 ` [Bug target/57669] " pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: jtaylor.debian at gmail dot com @ 2013-06-21 15:50 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57669

Julian Taylor <jtaylor.debian at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jtaylor.debian at gmail dot com

--- Comment #1 from Julian Taylor <jtaylor.debian at gmail dot com> ---
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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug target/57669] Incorrect floating point values with 32-bit compile
  2013-06-21 12:33 [Bug c/57669] New: Incorrect floating point values with 32-bit compile oliverst at online dot de
  2013-06-21 15:50 ` [Bug c/57669] " jtaylor.debian at gmail dot com
@ 2013-06-21 16:27 ` pinskia at gcc dot gnu.org
  2013-06-21 16:38 ` oliverst at online dot de
  2013-06-24 10:53 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-06-21 16:27 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57669

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |target

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This sounds like bug 323.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug target/57669] Incorrect floating point values with 32-bit compile
  2013-06-21 12:33 [Bug c/57669] New: Incorrect floating point values with 32-bit compile oliverst at online dot de
  2013-06-21 15:50 ` [Bug c/57669] " jtaylor.debian at gmail dot com
  2013-06-21 16:27 ` [Bug target/57669] " pinskia at gcc dot gnu.org
@ 2013-06-21 16:38 ` oliverst at online dot de
  2013-06-24 10:53 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: oliverst at online dot de @ 2013-06-21 16:38 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57669

--- Comment #3 from Oliver Stoeneberg <oliverst at online dot de> ---
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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug target/57669] Incorrect floating point values with 32-bit compile
  2013-06-21 12:33 [Bug c/57669] New: Incorrect floating point values with 32-bit compile oliverst at online dot de
                   ` (2 preceding siblings ...)
  2013-06-21 16:38 ` oliverst at online dot de
@ 2013-06-24 10:53 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-06-24 10:53 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57669

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Dup.

*** This bug has been marked as a duplicate of bug 323 ***


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-06-24 10:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-21 12:33 [Bug c/57669] New: Incorrect floating point values with 32-bit compile oliverst at online dot de
2013-06-21 15:50 ` [Bug c/57669] " jtaylor.debian at gmail dot com
2013-06-21 16:27 ` [Bug target/57669] " pinskia at gcc dot gnu.org
2013-06-21 16:38 ` oliverst at online dot de
2013-06-24 10:53 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).