unittests failures: constant folding of cos function gives different result then function call
Iain Buclaw
ibuclaw at ubuntu.com
Wed Jul 10 06:40:10 PDT 2013
On 9 July 2013 17:08, Johannes Pfau <nospam at example.com> wrote:
> One of the tests in std.complex is failing because cos(LITERAL) and
> cos(VARIABLE) return different results. AFAICS this happens only if the
> parameter doesn't fit in 80bits and needs to be rounded. If
> LITERAL/VARIABLE are values which fit exactly in 80bits we get the same
> result. It's exactly the same situation in GCC.
> I guess we just get higher precision when evaluating those functions
> using constant folding as the LITERAL value is probably not rounded
> before evaluating the cos.
>
> So should we try to make the constant folding produce exactly the same
> value as the runtime version or do we want to keep the higher precision
> and adjust the unit test to use different values?
>
If gcc is the same, I'd just accept that's just how the backend works.
Also, with dmd, does it not use inline assembler for these routines -
so the calculated value is always the same?
--
Iain Buclaw
*(p < e ? p++ : p) = (c & 0x0f) + '0';
More information about the D.gnu
mailing list