This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

optimization bug gcc 4.1.2


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

inline double abs(double x)
{
	// remove sign bit
	*reinterpret_cast<long long int*>(&x) &= 0x7FFFFFFFFFFFFFFFLL;
	return x;
}

int main(int argc, char *argv[])
{
	std::cout << "abs = " << abs(-2.1) << std::endl;
}


This simple code works correct in DEBUG. But it works INCORRECT in
release (-O2)

gcc 4.1.2/4.1.1
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIt5bdzcPJMsK6QP8RAgvfAJ94tuXYQIGzBfktUi3dkQcXSsigzQCZAbAF
fxSsDpV4w7VoCv6Y06wSscs=
=1PBk
-----END PGP SIGNATURE-----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]