Skip to content

The function genericGetVectorWith should not to be inlined. #17

@tangboyun

Description

@tangboyun

I 've defined a data like this:

getBasicData :: Int -> Get BasicData
getBasicData n = BasicData
             <$> genericGetVectorWith (return n) getInt32le
             <*> genericGetVectorWith (return n) getInt32le
             <*> genericGetVectorWith (return n) getInt32le
             <*> genericGetVectorWith (return n) getInt32le
             <*> genericGetVectorWith (return n) getFloatle
             <*> genericGetVectorWith (return n) getWord8

While trying to print the data, it outputs:

[4850337,4850337,4850337,4850344,4850344,4850344,4850344,4850344,4850344,4850344]
[4850337,4850337,4850337,4850344,4850344,4850344,4850344,4850344,4850344,4850344]
[4850337,4850337,4850337,4850344,4850344,4850344,4850344,4850344,4850344,4850344]
[4850337,4850337,4850337,4850344,4850344,4850344,4850344,4850344,4850344,4850344]
[0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8]
[2,3,1,2,3,3,3,3,3,1]

It should be:

[-140392093,-140392093,-140392093,-140392093,-140392093,-140392093,-140392093,-140392093,-140392093,-140392093]
[316,2999,6687,0,278,1904,4098,5799,7449,9230]
[2956,6642,8567,232,1861,4055,5755,7407,9180,9340]
[4850337,4850337,4850337,4850344,4850344,4850344,4850344,4850344,4850344,4850344]
[0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8]
[2,3,1,2,3,3,3,3,3,1]

When mark this fuction as NOINLINE or set ghc option -fno-cse, the bug disappeared.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions