public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/59089] New: sin and/or cos produce bogus results with -O2
@ 2013-11-12 14:49 terra at gnome dot org
  2013-11-12 14:51 ` [Bug c/59089] " terra at gnome dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: terra at gnome dot org @ 2013-11-12 14:49 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 59089
           Summary: sin and/or cos produce bogus results with -O2
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: terra at gnome dot org

Created attachment 31199
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31199&action=edit
sc.c

welinder@sherwood:~> gcc --version
gcc (SUSE Linux) 4.7.1 20120723 [gcc-4_7-branch revision 189773]

When sin(x) and cos(x) are used near each other and -O2 is active,
results are utterly unreliable:

welinder@sherwood:~> gcc -Wall -O0 sc.c -lm
welinder@sherwood:~> ./a.out 1e19
cot(1e+19) = 0.40440089012342833596
welinder@sherwood:~> gcc -Wall -O2 sc.c -lm
welinder@sherwood:~> ./a.out 1e19
cot(1e+19) = 0.60484784464511465174



Reference value from
http://www.wolframalpha.com/input/?i=Cot[10^19]&a=TrigRD_R
--> 0.404400890123428300526065555419647330231956673028985010736178...

Further info: -O2 uses sincos, not sin and cos:

welinder@sherwood:~> gcc -Wall -O2 sc.c
/tmp/ccouebOR.o: In function `gnm_cot':
sc.c:(.text+0xd): undefined reference to `sincos'
collect2: error: ld returned 1 exit status
welinder@sherwood:~> gcc -Wall -O0 sc.c
/tmp/ccR0uAFj.o: In function `gnm_cot':
sc.c:(.text+0x1b): undefined reference to `sin'
sc.c:(.text+0x3a): undefined reference to `cos'
collect2: error: ld returned 1 exit status


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

* [Bug c/59089] sin and/or cos produce bogus results with -O2
  2013-11-12 14:49 [Bug c/59089] New: sin and/or cos produce bogus results with -O2 terra at gnome dot org
@ 2013-11-12 14:51 ` terra at gnome dot org
  2013-11-12 15:34 ` octoploid at yandex dot com
  2013-11-14  8:50 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: terra at gnome dot org @ 2013-11-12 14:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from M Welinder <terra at gnome dot org> ---
Version and arch details:

welinder@sherwood:~> gcc -v -Wall -O0 sc.c -lm
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/4.7/lto-wrapper
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
--enable-languages=c,c++,objc,fortran,obj-c++,java,ada
--enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.7
--enable-ssp --disable-libssp --disable-libitm --disable-plugin
--with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux'
--disable-libgcj --disable-libmudflap --with-slibdir=/lib64 --with-system-zlib
--enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch
--enable-version-specific-runtime-libs --enable-linker-build-id
--program-suffix=-4.7 --enable-linux-futex --without-system-libunwind
--with-arch-32=i586 --with-tune=generic --build=x86_64-suse-linux
Thread model: posix
gcc version 4.7.1 20120723 [gcc-4_7-branch revision 189773] (SUSE Linux) 
COLLECT_GCC_OPTIONS='-v' '-Wall' '-O0' '-mtune=generic' '-march=x86-64'
 /usr/lib64/gcc/x86_64-suse-linux/4.7/cc1 -quiet -v sc.c -quiet -dumpbase sc.c
-mtune=generic -march=x86-64 -auxbase sc -O0 -Wall -version -o /tmp/cc9NYeac.s
GNU C (SUSE Linux) version 4.7.1 20120723 [gcc-4_7-branch revision 189773]
(x86_64-suse-linux)
    compiled by GNU C version 4.7.1 20120723 [gcc-4_7-branch revision 189773],
GMP version 5.0.5, MPFR version 3.1.0-p1, MPC version 0.8.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib64/gcc/x86_64-suse-linux/4.7/include
 /usr/local/include
 /usr/lib64/gcc/x86_64-suse-linux/4.7/include-fixed
 /usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/include
 /usr/include
End of search list.
GNU C (SUSE Linux) version 4.7.1 20120723 [gcc-4_7-branch revision 189773]
(x86_64-suse-linux)
    compiled by GNU C version 4.7.1 20120723 [gcc-4_7-branch revision 189773],
GMP version 5.0.5, MPFR version 3.1.0-p1, MPC version 0.8.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: e3eb1496554b3c5a9dcd68c49e292596
COLLECT_GCC_OPTIONS='-v' '-Wall' '-O0' '-mtune=generic' '-march=x86-64'
 /usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/as -v
--64 -o /tmp/ccOxQnNc.o /tmp/cc9NYeac.s
GNU assembler version 2.22 (x86_64-suse-linux) using BFD version (GNU Binutils;
openSUSE 12.2) 2.22
COMPILER_PATH=/usr/lib64/gcc/x86_64-suse-linux/4.7/:/usr/lib64/gcc/x86_64-suse-linux/4.7/:/usr/lib64/gcc/x86_64-suse-linux/:/usr/lib64/gcc/x86_64-suse-linux/4.7/:/usr/lib64/gcc/x86_64-suse-linux/:/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/
LIBRARY_PATH=/usr/lib64/gcc/x86_64-suse-linux/4.7/:/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/lib/:/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-Wall' '-O0' '-mtune=generic' '-march=x86-64'
 /usr/lib64/gcc/x86_64-suse-linux/4.7/collect2 --build-id --eh-frame-hdr -m
elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../lib64/crt1.o
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../lib64/crti.o
/usr/lib64/gcc/x86_64-suse-linux/4.7/crtbegin.o
-L/usr/lib64/gcc/x86_64-suse-linux/4.7
-L/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../lib64 -L/lib/../lib64
-L/usr/lib/../lib64
-L/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/lib
-L/usr/lib64/gcc/x86_64-suse-linux/4.7/../../.. /tmp/ccOxQnNc.o -lm -lgcc
--as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed
/usr/lib64/gcc/x86_64-suse-linux/4.7/crtend.o
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../lib64/crtn.o


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

* [Bug c/59089] sin and/or cos produce bogus results with -O2
  2013-11-12 14:49 [Bug c/59089] New: sin and/or cos produce bogus results with -O2 terra at gnome dot org
  2013-11-12 14:51 ` [Bug c/59089] " terra at gnome dot org
@ 2013-11-12 15:34 ` octoploid at yandex dot com
  2013-11-14  8:50 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: octoploid at yandex dot com @ 2013-11-12 15:34 UTC (permalink / raw)
  To: gcc-bugs

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

Markus Trippelsdorf <octoploid at yandex dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |octoploid at yandex dot com

--- Comment #2 from Markus Trippelsdorf <octoploid at yandex dot com> ---
That is not a gcc issue, it's a glibc problem.
There were a lot of improvements in that area in recent months.
So I would recommend that you update your glibc to get better results.


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

* [Bug c/59089] sin and/or cos produce bogus results with -O2
  2013-11-12 14:49 [Bug c/59089] New: sin and/or cos produce bogus results with -O2 terra at gnome dot org
  2013-11-12 14:51 ` [Bug c/59089] " terra at gnome dot org
  2013-11-12 15:34 ` octoploid at yandex dot com
@ 2013-11-14  8:50 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-11-14  8:50 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Indeed a glibc bug.


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

end of thread, other threads:[~2013-11-14  8:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-12 14:49 [Bug c/59089] New: sin and/or cos produce bogus results with -O2 terra at gnome dot org
2013-11-12 14:51 ` [Bug c/59089] " terra at gnome dot org
2013-11-12 15:34 ` octoploid at yandex dot com
2013-11-14  8:50 ` 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).