haskell / haskell/double-conversion

Test failure when compiled with -O0

Open
#26 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
18
Forks
37
PR merge metrics
No merged PRs in 30d

Description

If I compile with `-O0`, I get the following test failure:

```
*** Failed! Falsifiable (after 1 test):
0.0
0.0
(used seed -8074436915145524066)
t_shortest: [Failed]
*** Failed! Falsifiable (after 1 test):
0.0
0.0
(used seed 5824167789149766384)
Regressions:
toShortest_overflow: [OK]

Properties Test Cases Total
Passed 0 1 1
Failed 2 0 2
Total 2 1 3
```

The test code in question is https://github.com/bos/double-conversion/blob/e4b7956d51fbb79ada95412519bd2a6a680def23/tests/Properties.hs#L9-L13

where `a = 0.0`, `b = 0.0`.

The problem seems to be the [use of](https://github.com/bos/double-conversion/blob/e4b7956d51fbb79ada95412519bd2a6a680def23/Data/Double/Conversion/ByteString.hs#L72) `realToFrac (0.0 / 0.0)`. Note that `0.0/0.0` is `NaN`.

* With `-O`, `realToFrac NaN` returns `NaN`
* With `-O0`, `realToFrac NaN` returns `-Infinity`

You would expect `realToFrac :: Double -> Double` to always be `id`, but apparently that is not the case in GHC right now. It is so only if compile with optimisations.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.