This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/60637] New: --fast-math breaks std::signbit function
- From: "magicstix at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 24 Mar 2014 17:40:48 +0000
- Subject: [Bug libstdc++/60637] New: --fast-math breaks std::signbit function
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60637
Bug ID: 60637
Summary: --fast-math breaks std::signbit function
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: magicstix at gmail dot com
On GCC 4.4.6 and GCC 4.8.2, the std::signbit gives invalid results when code is
compiled with the --fast-math option.
The following minimal test case can replicate the problem:
#include <iostream>
#include <cmath>
int main(int argc, char** argv)
{
long double ld = -5.3165867831218916301793863361917824e-2467L;
std::cout << std::signbit(ld) << std::endl;
return 0;
}
When compiled with --fast-math, this test case prints out an invalid result of
0.
I first noticed the problem in working with the boost libraries (specifically
their bessel function implementation). The boost dev-team was able to narrow
down the problem to the std::signbit function.
The bug has been replicated on RHEL 6.3's stock GCC 4.4.6 and a
compiled-from-source GCC 4.8.2. The development system exhibiting the behavior
is a stock 64-bit RHEL 6.3 Linux install.
The bug has also been found to occur when compiling the code using Intel's C++
compiler using -std=c++11 (which relies on GCC's standard C++ libraries).
I also carried out a sanity test on GCC 4.1.2 and found that the problem *does
not* occur, indicating a regression at some point between 4.1.2 and 4.4.6.
My output from gcc -v:
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --disable-multilib
Thread model: posix
gcc version 4.8.2 (GCC)