public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107117] New: "atan2" fails to set the floating-point inexact exception when it should, in some cases
@ 2022-10-01 23:51 Jay_Reynolds_Freeman at mac dot com
  2022-10-01 23:52 ` [Bug c++/107117] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Jay_Reynolds_Freeman at mac dot com @ 2022-10-01 23:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107117

            Bug ID: 107117
           Summary: "atan2" fails to set the floating-point inexact
                    exception when it should, in some cases
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Jay_Reynolds_Freeman at mac dot com
  Target Milestone: ---

Created attachment 53649
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53649&action=edit
.ii file generated when compiling the test case with -v and -save-tenps

THE PROBLEM I am reporting is instances in which function "atan2" fails to set
the floating-point inexact exception when it should. They occur when compiling
and running on a Raspberry Pi 4, using the 64-bit version of bullseye and the
version of g++ that came with it (which is "g++ (Debian 10.2.1-6) 10.2.1
20210110"). The problem is repeatable. It does *not* occur for all arguments of
atan2 -- I have tested many, and generally the floating-point exception is
correctly set. I have also tested numerous other floating-point functions, and
have noticed no other errors, at least, not yet. 

I have tested the same source file on an Intel Macintosh using Apple's version
of clang to compile, and the floating-point exception is set correctly there.

I have previously reported this problem as a Raspberry Pi issue, at
https://github.com/RPi-Distro/repo/issues/310. A user there tested the code on
a different system (Ubuntu 22.04.1 LTS (x86_64)), and reported that the
floating-point exception was not set on that system. Therefor I am now
reporting the issue as a gcc problem.

I will append below the output from building my test file with -v -save-temps.
That file shows the version of g++, which was provided completely built with
the installation of Raspberry Pi Linux (Debian GNU/Linux 11 (bullseye) -- and
note that this is a 64-bit installation).

Once the test case is compiled, the error is demonstrated simply by running it,
via printf output.

The test case compiled with no warnings.

I shall attach a .i file. Here is the output from -v -save-temps:

#### SNIP ####

jayfreeman@raspberrypi:~/Developer/Bugs $ g++ -v -save-temps AtanBug.c++ -lm -o
AtanBug
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/10/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 10.2.1-6'
--with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-10
--program-prefix=aarch64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-libquadmath --disable-libquadmath-support --enable-plugin
--enable-default-pie --with-system-zlib --enable-libphobos-checking=release
--with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch
--enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release
--build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu
--with-build-config=bootstrap-lto-lean --enable-link-mutex
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.1 20210110 (Debian 10.2.1-6) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o' 'AtanBug' '-shared-libgcc'
'-mlittle-endian' '-mabi=lp64'
 /usr/lib/gcc/aarch64-linux-gnu/10/cc1plus -E -quiet -v -imultiarch
aarch64-linux-gnu -D_GNU_SOURCE AtanBug.c++ -mlittle-endian -mabi=lp64
-fpch-preprocess -fasynchronous-unwind-tables -o AtanBug.ii
ignoring duplicate directory "/usr/include/aarch64-linux-gnu/c++/10"
ignoring nonexistent directory "/usr/local/include/aarch64-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/aarch64-linux-gnu/10/include-fixed"
ignoring nonexistent directory
"/usr/lib/gcc/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/10
 /usr/include/aarch64-linux-gnu/c++/10
 /usr/include/c++/10/backward
 /usr/lib/gcc/aarch64-linux-gnu/10/include
 /usr/local/include
 /usr/include/aarch64-linux-gnu
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o' 'AtanBug' '-shared-libgcc'
'-mlittle-endian' '-mabi=lp64'
 /usr/lib/gcc/aarch64-linux-gnu/10/cc1plus -fpreprocessed AtanBug.ii -quiet
-dumpbase AtanBug.c++ -mlittle-endian -mabi=lp64 -auxbase AtanBug -version
-fasynchronous-unwind-tables -o AtanBug.s
GNU C++14 (Debian 10.2.1-6) version 10.2.1 20210110 (aarch64-linux-gnu)
        compiled by GNU C version 10.2.1 20210110, GMP version 6.2.1, MPFR
version 4.1.0, MPC version 1.2.0, isl version isl-0.23-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++14 (Debian 10.2.1-6) version 10.2.1 20210110 (aarch64-linux-gnu)
        compiled by GNU C version 10.2.1 20210110, GMP version 6.2.1, MPFR
version 4.1.0, MPC version 1.2.0, isl version isl-0.23-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 7ff9b3e77ba341f92c3fc11acba5d5f9
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o' 'AtanBug' '-shared-libgcc'
'-mlittle-endian' '-mabi=lp64'
 as -v -EL -mabi=lp64 -o AtanBug.o AtanBug.s
GNU assembler version 2.35.2 (aarch64-linux-gnu) using BFD version (GNU
Binutils for Debian) 2.35.2
COMPILER_PATH=/usr/lib/gcc/aarch64-linux-gnu/10/:/usr/lib/gcc/aarch64-linux-gnu/10/:/usr/lib/gcc/aarch64-linux-gnu/:/usr/lib/gcc/aarch64-linux-gnu/10/:/usr/lib/gcc/aarch64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/aarch64-linux-gnu/10/:/usr/lib/gcc/aarch64-linux-gnu/10/../../../aarch64-linux-gnu/:/usr/lib/gcc/aarch64-linux-gnu/10/../../../../lib/:/lib/aarch64-linux-gnu/:/lib/../lib/:/usr/lib/aarch64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/aarch64-linux-gnu/10/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o' 'AtanBug' '-shared-libgcc'
'-mlittle-endian' '-mabi=lp64'
 /usr/lib/gcc/aarch64-linux-gnu/10/collect2 -plugin
/usr/lib/gcc/aarch64-linux-gnu/10/liblto_plugin.so
-plugin-opt=/usr/lib/gcc/aarch64-linux-gnu/10/lto-wrapper
-plugin-opt=-fresolution=AtanBug.res -plugin-opt=-pass-through=-lgcc_s
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc
-plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id
--eh-frame-hdr --hash-style=gnu --as-needed -dynamic-linker
/lib/ld-linux-aarch64.so.1 -X -EL -maarch64linux --fix-cortex-a53-843419 -pie
-o AtanBug /usr/lib/gcc/aarch64-linux-gnu/10/../../../aarch64-linux-gnu/Scrt1.o
/usr/lib/gcc/aarch64-linux-gnu/10/../../../aarch64-linux-gnu/crti.o
/usr/lib/gcc/aarch64-linux-gnu/10/crtbeginS.o
-L/usr/lib/gcc/aarch64-linux-gnu/10
-L/usr/lib/gcc/aarch64-linux-gnu/10/../../../aarch64-linux-gnu
-L/usr/lib/gcc/aarch64-linux-gnu/10/../../../../lib -L/lib/aarch64-linux-gnu
-L/lib/../lib -L/usr/lib/aarch64-linux-gnu -L/usr/lib/../lib
-L/usr/lib/gcc/aarch64-linux-gnu/10/../../.. AtanBug.o -lstdc++ -lm -lgcc_s
-lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/aarch64-linux-gnu/10/crtendS.o
/usr/lib/gcc/aarch64-linux-gnu/10/../../../aarch64-linux-gnu/crtn.o
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o' 'AtanBug' '-shared-libgcc'
'-mlittle-endian' '-mabi=lp64'

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

* [Bug c++/107117] "atan2" fails to set the floating-point inexact exception when it should, in some cases
  2022-10-01 23:51 [Bug c++/107117] New: "atan2" fails to set the floating-point inexact exception when it should, in some cases Jay_Reynolds_Freeman at mac dot com
@ 2022-10-01 23:52 ` pinskia at gcc dot gnu.org
  2022-10-01 23:53 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-01 23:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107117

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This might be a bug with glibc rather than GCC ...

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

* [Bug c++/107117] "atan2" fails to set the floating-point inexact exception when it should, in some cases
  2022-10-01 23:51 [Bug c++/107117] New: "atan2" fails to set the floating-point inexact exception when it should, in some cases Jay_Reynolds_Freeman at mac dot com
  2022-10-01 23:52 ` [Bug c++/107117] " pinskia at gcc dot gnu.org
@ 2022-10-01 23:53 ` pinskia at gcc dot gnu.org
  2022-10-01 23:53 ` Jay_Reynolds_Freeman at mac dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-01 23:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107117

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Or it might be that gcc constant folds this case ...

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

* [Bug c++/107117] "atan2" fails to set the floating-point inexact exception when it should, in some cases
  2022-10-01 23:51 [Bug c++/107117] New: "atan2" fails to set the floating-point inexact exception when it should, in some cases Jay_Reynolds_Freeman at mac dot com
  2022-10-01 23:52 ` [Bug c++/107117] " pinskia at gcc dot gnu.org
  2022-10-01 23:53 ` pinskia at gcc dot gnu.org
@ 2022-10-01 23:53 ` Jay_Reynolds_Freeman at mac dot com
  2022-10-02  8:12 ` [Bug middle-end/107117] "atan2" fails to set the floating-point inexact exception due to constant folding, " schwab@linux-m68k.org
  2022-10-06  9:54 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: Jay_Reynolds_Freeman at mac dot com @ 2022-10-01 23:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107117

Jay Reynolds Freeman <Jay_Reynolds_Freeman at mac dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Jay_Reynolds_Freeman at mac dot co
                   |                            |m

--- Comment #3 from Jay Reynolds Freeman <Jay_Reynolds_Freeman at mac dot com> ---
Created attachment 53650
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53650&action=edit
.c++ source file for test case demonstrating the bug.

Also adding a copy of the un-preprocessed .c++ file, for reference.

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

* [Bug middle-end/107117] "atan2" fails to set the floating-point inexact exception  due to constant folding, in some cases
  2022-10-01 23:51 [Bug c++/107117] New: "atan2" fails to set the floating-point inexact exception when it should, in some cases Jay_Reynolds_Freeman at mac dot com
                   ` (2 preceding siblings ...)
  2022-10-01 23:53 ` Jay_Reynolds_Freeman at mac dot com
@ 2022-10-02  8:12 ` schwab@linux-m68k.org
  2022-10-06  9:54 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: schwab@linux-m68k.org @ 2022-10-02  8:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107117

--- Comment #4 from Andreas Schwab <schwab@linux-m68k.org> ---
Whether the inexact exception is raised or not is unspecified in general, and
atan2 is no exception.

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

* [Bug middle-end/107117] "atan2" fails to set the floating-point inexact exception  due to constant folding, in some cases
  2022-10-01 23:51 [Bug c++/107117] New: "atan2" fails to set the floating-point inexact exception when it should, in some cases Jay_Reynolds_Freeman at mac dot com
                   ` (3 preceding siblings ...)
  2022-10-02  8:12 ` [Bug middle-end/107117] "atan2" fails to set the floating-point inexact exception due to constant folding, " schwab@linux-m68k.org
@ 2022-10-06  9:54 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-10-06  9:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107117

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Btw, we only avoid inexact constant foldings for -frounding-math, not with
-ftrapping-math (which guards FP exception state).  See do_mpfr_ckconv.
So we could do better here if we want (but then if at runtime the inexact
exception is raised is unspecified).

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

end of thread, other threads:[~2022-10-06  9:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-01 23:51 [Bug c++/107117] New: "atan2" fails to set the floating-point inexact exception when it should, in some cases Jay_Reynolds_Freeman at mac dot com
2022-10-01 23:52 ` [Bug c++/107117] " pinskia at gcc dot gnu.org
2022-10-01 23:53 ` pinskia at gcc dot gnu.org
2022-10-01 23:53 ` Jay_Reynolds_Freeman at mac dot com
2022-10-02  8:12 ` [Bug middle-end/107117] "atan2" fails to set the floating-point inexact exception due to constant folding, " schwab@linux-m68k.org
2022-10-06  9:54 ` 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).