relic-toolkit / relic

Code
Other
453 stars 179 forks source link

Some parameters should be const #226

Closed jgdumas closed 2 years ago

jgdumas commented 2 years ago

modulus (second argument) should be const in rand_mod? It is even copied to t ..?

dfaranha commented 2 years ago

BTW, thanks for spotting all these places needing const-correctness annotations!

I procrastinated doing this over EPX for far too long, because I was considering moving from structs to arrays (like FPX), but that should have been settled now.

jgdumas commented 2 years ago

Well, yeah it seems in fact that there are quite a bunch of them! I undergo doing some, but not sure I'll do them all ;-)

dfaranha commented 2 years ago

I would not go as far as FPX yet, because the type changes depending on the memory allocator settings and it might get weird!

jgdumas commented 2 years ago

ah, well in fact when changing const here and there, it requires to then change in other places, and so on and so forth. So right now indeed do not have any more warning nor inconsistent declarations/implementations, but I could not avoid to go through fpx for that ... For now both auto/dynamic seem to compile and all checks pass. But nevermind, just discard it if things go weird.

dfaranha commented 2 years ago

This should be fairly inoffensive and ready to merge. I will do it next weekend, and take the opportunity to complete coverage of const-correctness in the whole library!