------- Comment #3 from stewart at flamingspork dot com 2009-02-18 11:20 ------- To implement a work around for us, I'm proposing the patch below. - the tmp2 being volatile was for who knows what reason (old code) - The check should (on c99 systems or those with the right compile options enabled, which we do have) detect that we calculate at 80bits but store at 64. - the volatile temp should ensure a write to memory (and subsequent read) - where the check is false, the whole code path should be optimised out.
Perhaps it should also be surrounded by an ifdef for the specific gcc version (3.4)? Thoughts are very welcome. === modified file 'drizzled/function/math/round.cc' --- drizzled/function/math/round.cc 2008-12-16 06:21:46 +0000 +++ drizzled/function/math/round.cc 2009-02-18 09:59:40 +0000 @@ -111,14 +111,22 @@ tmp2 is here to avoid return the value with 80 bit precision This will fix that the test round(0.1,1) = round(0.1,1) is true */ - volatile double tmp2; + double tmp2; tmp=(abs_dec < array_elements(log_10) ? log_10[abs_dec] : pow(10.0,(double) abs_dec)); + double value_times_tmp= value * tmp; + + if(sizeof(double) < sizeof(double_t)) + { + volatile double t= value_times_tmp; + value_times_tmp= t; + } + if (dec_negative && isinf(tmp)) tmp2= 0; - else if (!dec_negative && isinf(value * tmp)) + else if (!dec_negative && isinf(value_times_tmp)) tmp2= value; else if (truncate) { -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39228