public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/113578] New: Incorrect signbit for -nan on RISC-V
@ 2024-01-24 11:40 redi at gcc dot gnu.org
  2024-01-24 11:41 ` [Bug target/113578] Incorrect sign printed " redi at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2024-01-24 11:40 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113578
           Summary: Incorrect signbit for -nan on RISC-V
           Product: gcc
           Version: 11.4.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
                CC: doko at gcc dot gnu.org
  Target Milestone: ---
            Target: riscv64-linux-gnu

int main()
{
  float f = std::bit_cast<float>(0xfff80000);
  __builtin_printf("%f %d\n", f, __builtin_signbit(f));
}


With no optimization this prints:

nan 1


With optimization it prints:

-nan 1


i.e. signbit is always set, but sometimes the nan is printed as positive.

g++ -v:

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/riscv64-linux-gnu/11/lto-wrapper
Target: riscv64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
11.4.0-1ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-11
--program-prefix=riscv64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-gnu-unique-object --disable-libitm --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
--disable-werror --disable-multilib --with-arch=rv64gc --with-abi=lp64d
--enable-checking=release --build=riscv64-linux-gnu --host=riscv64-linux-gnu
--target=riscv64-linux-gnu --with-build-config=bootstrap-lto-lean
--enable-link-serialization=4
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04) 

Originally reported to
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1059340

I've only tested this with Ubuntu's gcc, I haven't tried a build of upstream
GCC, nor a newer version. Sorry if it's Debian specific.

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

end of thread, other threads:[~2024-05-15 11:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-24 11:40 [Bug target/113578] New: Incorrect signbit for -nan on RISC-V redi at gcc dot gnu.org
2024-01-24 11:41 ` [Bug target/113578] Incorrect sign printed " redi at gcc dot gnu.org
2024-01-24 12:28 ` jsm28 at gcc dot gnu.org
2024-01-24 17:34 ` pinskia at gcc dot gnu.org
2024-01-24 17:42 ` redi at gcc dot gnu.org
2024-01-24 17:56 ` redi at gcc dot gnu.org
2024-05-10 11:48 ` redi at gcc dot gnu.org
2024-05-10 21:32 ` andrew at sifive dot com
2024-05-13 11:09 ` redi at gcc dot gnu.org
2024-05-13 22:36 ` andrew at sifive dot com
2024-05-15 11:13 ` redi 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).