GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2019-07-07T18:52:54Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/5944Bad hpc hash function2019-07-07T18:52:54Zlennart@augustsson.netBad hpc hash functionIn the hpc module Trace.Hpc.Util there is the following code:
```
instance (HpcHash a,HpcHash b) => HpcHash (a,b) where
toHash (a,b) = toHash a * 33 `hxor` toHash b
```
This is bad and I can only presume that what was actually intend...In the hpc module Trace.Hpc.Util there is the following code:
```
instance (HpcHash a,HpcHash b) => HpcHash (a,b) where
toHash (a,b) = toHash a * 33 `hxor` toHash b
```
This is bad and I can only presume that what was actually intended was
```
instance (HpcHash a,HpcHash b) => HpcHash (a,b) where
toHash (a,b) = (toHash a * 33) `hxor` toHash b
```
Otherwise a hash of 0 for a will result in a total hash of 0.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------- |
| Version | 7.2.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Code Coverage |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Bad hpc hash function","status":"New","operating_system":"","component":"Code Coverage","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"andy@galois.com"},"version":"7.2.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"In the hpc module Trace.Hpc.Util there is the following code:\r\n\r\n{{{\r\ninstance (HpcHash a,HpcHash b) => HpcHash (a,b) where\r\n toHash (a,b) = toHash a * 33 `hxor` toHash b\r\n}}}\r\n\r\nThis is bad and I can only presume that what was actually intended was\r\n\r\n{{{\r\ninstance (HpcHash a,HpcHash b) => HpcHash (a,b) where\r\n toHash (a,b) = (toHash a * 33) `hxor` toHash b\r\n}}}\r\n\r\nOtherwise a hash of 0 for a will result in a total hash of 0.\r\n","type_of_failure":"OtherFailure","blocking":[]} -->7.4.2Simon MarlowSimon Marlow