This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/16607] New: Incorrect FP code generated in member data initialization
- From: "npr1 at suomi24 dot fi" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 Jul 2004 17:20:52 -0000
- Subject: [Bug c++/16607] New: Incorrect FP code generated in member data initialization
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
In some conditions a member initializer of double data is handled in single
precision.
Attached is a quite fragile minimized test program. In it, the bug only surfaces
in inlined code, i.e. compiled with -O.
At least GCC 3.3, 3.3.3 and 3.4.1 are affected. A test on GCC 2.95.4 on i686-pc-
linux-gnu didn't show the bug. It might be x86 only, as the test program doesn't
show it with GCC 3.3 on sparc-sun-solaris2.8.
For example, "gcc -v" of the 3.3.3:
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/
usr/share/info --enable-shared --enable-threads=posix --disable-checking --
disable-libunwind-exceptions --with-system-zlib --enable-__cxa_atexit --
host=i386-redhat-linux
Thread model: posix
gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)
/* $ g++ -Wall -O gccbug.cpp && ./a.out
* -1.19209e-07 0
* 0 1.19209e-07
* $ g++ -Wall -O0 gccbug.cpp && ./a.out
* 0 1.19209e-07
* 0 1.19209e-07
*/
int printf(const char*, ...);
struct C {
double x;
C(double x_) : x(x_) {
printf(" ");
printf("%g %g\n", x - x_, x - float(x_));
}
};
void f(float x) {
const double y = x * .9f;
if (x) {
new C(y);
new C(y);
}
}
int main() {
f(3);
return 0;
}
--
Summary: Incorrect FP code generated in member data
initialization
Product: gcc
Version: 3.4.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: npr1 at suomi24 dot fi
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16607