[Bug target/57484] 'std::numeric_limits< T >::signaling_NaN()' signaling-bit is incorrect for x86 32-bit.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57484 --- Comment #19 from Charles L. Wilcox --- (In reply to Uroš Bizjak from comment #11) > On an x86 target using the legacy x87 instructions and the 80-bit registers, > a load of a 64-bit or 32-bit value in memory into the 80-bit registers > counts as a format conversion and an signaling NaN input will turn into a > quiet NaN in the register format. Does this mean if a 80-bit sNaN was generated and loaded into a register it was still have the signaling bit set correctly? And if so, could this value then be down-converted to a 32 or 64-bit float? In C++: float float32_snan const = static_cast< float >( std::numeric_limits< long double >::signaling_NaN() ); double float64_snan const = static_cast< double >( std::numeric_limits< long double >::signaling_NaN() ); Or, is the "cast" here a format conversion, causing the signaling NaN to convert to a quiet NAN?
[Bug target/57484] 'std::numeric_limits< T >::signaling_NaN()' signaling-bit is incorrect for x86 32-bit.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57484 --- Comment #17 from Charles L. Wilcox --- Okay... so why not avoid the x87 restriction and use aliasing to load the correct value? I've updated my example to show how I was doing exactly this for some unit-test code I created.
[Bug target/57484] 'std::numeric_limits< T >::signaling_NaN()' signaling-bit is incorrect for x86 32-bit.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57484 Charles L. Wilcox changed: What|Removed |Added Attachment #30239|0 |1 is obsolete|| --- Comment #16 from Charles L. Wilcox --- Created attachment 30487 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30487&action=edit Expanded unit-test code to set signaling-NaN values via 'union' aliasing. Adding code to demonstrate how to generate a signaling-NaN using the existing ABI along with the "return through the x87 register" restriction.
[Bug middle-end/57484] 'std::numeric_limits< T >::signaling_NaN()' signaling-bit is incorrect for x86 32-bit.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57484 --- Comment #9 from Charles L. Wilcox --- So, given a month has gone by, should I expect any response or action on this bug-report?
[Bug middle-end/57484] 'std::numeric_limits< T >::signaling_NaN()' signaling-bit is incorrect for x86 32-bit.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57484 --- Comment #8 from Charles L. Wilcox --- FWIW, I tried this with g++ 4.8 on a 32-bit only system I have; it still produces erroneous sNaN values there: $ g++-4.8 -v Using built-in specs. COLLECT_GCC=g++-4.8 COLLECT_LTO_WRAPPER=/usr/lib/gcc/i486-linux-gnu/4.8/lto-wrapper Target: i486-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.8.1-1' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --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 --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-i386/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-i386 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-i386 --with-arch-directory=i386 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-targets=all --enable-multiarch --with-arch-32=i586 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu Thread model: posix gcc version 4.8.1 (Debian 4.8.1-1) $ g++-4.8 -Wall -Wextra test-signaling-nan.cpp $ ./a.out Signaling NaN for type "f" in hex is "7fe0". Signaling NaN's signaling-bit status for type "f" is set to "true". Quiet NaN for type "f" in hex is "7fc0". Quiet NaN's signaling-bit status for type "f" is set to "true". Signaling NaN for type "d" in hex is "7ffc". Signaling NaN's signaling-bit status for type "d" is set to "true". Quiet NaN for type "d" in hex is "7ff8". Quiet NaN's signaling-bit status for type "d" is set to "true".
[Bug c++/57484] 'std::numeric_limits< T >::signaling_NaN()' signaling-bit is incorrect for x86 32-bit.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57484 --- Comment #6 from Charles L. Wilcox --- (In reply to Paolo Carlini from comment #5) > Just to clarify that this is neither a library neither a C++ front-end > issue: just uses the various __builtin_nans* Paolo, I guessed this was the case from what I could tell using the debugger, but I wanted some confirmation that I was correct. Should the "Component" be changed from C++ to something else?
[Bug c++/57484] 'std::numeric_limits< T >::signaling_NaN()' signaling-bit is incorrect for x86 32-bit.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57484 --- Comment #3 from Charles L. Wilcox --- Daniel, Unfortunately, my initial machine, a laptop, decided to commit seppuku yesterday. Fortunately, the disk survived, I ported the code to another machine I have, and am still seeing similar results there. $ gcc -v 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='Debian 4.7.2-5' --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 --with-system-zlib --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 --enable-objc-gc --with-arch-32=i586 --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.2 (Debian 4.7.2-5) I updated my code to print out the full contents of the NaN values in hex. My machine produces the following output: $ g++ -Wall -Wextra test-signaling-nan.cpp -m32 $ ./a.out Signaling NaN for type "f" in hex is "7fe0". Signaling NaN's signaling-bit status for type "f" is set to "true". Quiet NaN for type "f" in hex is "7fc0". Quiet NaN's signaling-bit status for type "f" is set to "true". Signaling NaN for type "d" in hex is "7ffc". Signaling NaN's signaling-bit status for type "d" is set to "true". Quiet NaN for type "d" in hex is "7ff8". Quiet NaN's signaling-bit status for type "d" is set to "true". $ g++ -Wall -Wextra test-signaling-nan.cpp -m64 $ ./a.out Signaling NaN for type "f" in hex is "7fa0". Signaling NaN's signaling-bit status for type "f" is set to "false". Quiet NaN for type "f" in hex is "7fc0". Quiet NaN's signaling-bit status for type "f" is set to "true". Signaling NaN for type "d" in hex is "7ff4". Signaling NaN's signaling-bit status for type "d" is set to "false". Quiet NaN for type "d" in hex is "7ff8". Quiet NaN's signaling-bit status for type "d" is set to "true". The resulting values on 32-bit vs. 64-bit are different, and I believe the 64-bit values are the correct ones.
[Bug c++/57484] 'std::numeric_limits< T >::signaling_NaN()' signaling-bit is incorrect for x86 32-bit.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57484 Charles L. Wilcox changed: What|Removed |Added Attachment #30234|0 |1 is obsolete|| --- Comment #2 from Charles L. Wilcox --- Created attachment 30239 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30239&action=edit Updated test code to print out the full signaling and quiet NaN's values in hex.
[Bug c++/57484] New: 'std::numeric_limits< T >::signaling_NaN()' signaling-bit is incorrect for x86 32-bit.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57484 Bug ID: 57484 Summary: 'std::numeric_limits< T >::signaling_NaN()' signaling-bit is incorrect for x86 32-bit. Product: gcc Version: 4.7.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: zxClhzAApX1EdJwQANqrjLERmFeURQVy at cynd dot net Created attachment 30234 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30234&action=edit C++ test program to extract and display the signaling-bit of a signaling-NaN and a quiet-NaN. $ g++ -v Using built-in specs. COLLECT_GCC=g++ 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) What I expect: For 'float' and 'double' types when 'std::numeric_traits< T >::is_iec559' is 'true', 'std::numeric_traits< T >::signaling_NaN()' should generate a IEEE-754 value whose sign bit is '0', exponent bits are all '1', the highest significand bit is '0', and some other significant bit(s) are '1'. What I observe: - x86 32-bit: all expectations are met, except that the highest significand bit is '1'. ( This implies it is a quiet-NaN, not a signaling-NaN. ) - x86 64-bit: all expectations are met. My evidence: Attached is a test C++ program that extracts the IEEE-754 signaling bit value of both a signaling-NaN and a quiet-NaN, for 'float' and 'double' types, and prints the results to console. When compiling with '-m32', I see the unexpected behavior; when compiling with '-m64', I see the expected behavior. Compiler flags / command-line: - x86 32-bit: g++ -m32 -Wall -Wextra test-signaling-nan.cpp - x86 64-bit: g++ -m64 -Wall -Wextra test-signaling-nan.cpp Compilation errors / warnings: None.