edanor/umesimd

Const correctness of pointers

Closed this issue · 1 comments

Hi again,

we ran into some problems compiling the library, because of const correctness of pointers.

In our case, we assumed that the gather operation would be fine with a const pointer, since it semantics suggests that it only loads stuff and doesn't mess with the data.

For example:

SIMDVec_u & gather(uint64_t * baseAddr, SIMDVec_u const & indices); // current
SIMDVec_u & gather(uint64_t const * baseAddr, SIMDVec_u const & indices);  // our suggestion

//or

SIMDVec_u & gather(uint64_t * baseAddr, uint64_t* indices); // current
SIMDVec_u & gather(uint64_t const * baseAddr, uint64_t const * indices); // our suggestion

Is there a reason to not guarantee constness? If not I would open a pull request to fix at least the gather operations.

You are most definitely right. There is no reason why this shouldn't be 'const', and there are few why it should be. Feel free to pull, but mind that this change has to be fixed also in the interface definition, and all remaining plugins.