------- Comment #4 from ullner at gmail dot com  2010-03-08 17:59 -------
That still doesn't make sense.
1. Why does enabling -O3 (O1 and O2 does the same) remove this problem?
2. Why does storing the value in an intermediate variable make any change in
what the result is?

Consider without O3:
(long long)std::pow(2.0, 64); // Overflow.
(long long)std::pow(2.0, 64.0); // OK

double d1 = std::pow(2.0, 64);
(long long)d1; // Overflow
double d2 = std::pow(2.0, 64.0);
(long long)d2; // Overflow

long long l1 = d1; // l1 Overflows
long long l2 = d2; // l2 Overflows

Enabling -O3 causes every one of those that overflows to be OK. 


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43284

Reply via email to