https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65208
Bug ID: 65208
Summary: Floats sometimes rounded up instead of being truncated
on mips
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: wgh at beyondunreal dot com
Created attachment 34869
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34869&action=edit
preprocessed input
It seems like typical cast from double to unsigned sometimes rounds the result
up.
On my router, the attached code, compiled with the following commandline
mipsel-linux-uclibc-gcc -Wall -Wextra -O2 -static -std=c11 test.c
prints
0.7
i=1
i=0
The compiler generates no errors or warnings.
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/mipsel-linux-uclibc/gcc-bin/4.9.2/mipsel-linux-uclibc-gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/mipsel-linux-uclibc/4.9.2/lto-wrapper
Target: mipsel-linux-uclibc
Configured with:
/var/tmp/portage/cross-mipsel-linux-uclibc/gcc-4.9.2/work/gcc-4.9.2/configure
--host=x86_64-pc-linux-gnu --target=mipsel-linux-uclibc
--build=x86_64-pc-linux-gnu --prefix=/usr
--bindir=/usr/x86_64-pc-linux-gnu/mipsel-linux-uclibc/gcc-bin/4.9.2
--includedir=/usr/lib/gcc/mipsel-linux-uclibc/4.9.2/include
--datadir=/usr/share/gcc-data/mipsel-linux-uclibc/4.9.2
--mandir=/usr/share/gcc-data/mipsel-linux-uclibc/4.9.2/man
--infodir=/usr/share/gcc-data/mipsel-linux-uclibc/4.9.2/info
--with-gxx-include-dir=/usr/lib/gcc/mipsel-linux-uclibc/4.9.2/include/g++-v4
--with-python-dir=/share/gcc-data/mipsel-linux-uclibc/4.9.2/python
--enable-languages=c --enable-obsolete --enable-secureplt --disable-werror
--with-system-zlib --enable-nls --without-included-gettext
--enable-checking=release --with-bugurl=https://bugs.gentoo.org/
--with-pkgversion='Gentoo 4.9.2 p1.1, pie-0.6.2'
--enable-poison-system-directories --disable-shared --disable-shared
--disable-libatomic --with-sysroot=/usr/mipsel-linux-uclibc --disable-bootstrap
--disable-__cxa_atexit --enable-tls --disable-multilib --disable-altivec
--disable-fixed-point --with-abi= --disable-libgcj --disable-libgomp
--disable-libmudflap --disable-libssp --disable-libquadmath --enable-lto
--without-cloog --enable-libsanitizer
Thread model: posix
gcc version 4.9.2 (Gentoo 4.9.2 p1.1, pie-0.6.2)