Constantine: modular, high-performance, zero-dependency cryptography stack for verifiable computation, proof systems and blockchain protocols.
413
stars
44
forks
source link
Upstream regression: compiler refuses to convert cint to uint32 #469
Closed
mratsim closed 2 months ago
See: https://github.com/mratsim/constantine/actions/runs/11034017591/job/30646539242?pr=468
The flow:
Threadpool has a cint
numThreads
https://github.com/mratsim/constantine/blob/65147ed815d96fa94a05d307c1d9980877b7d0e8/constantine/threadpool/threadpool.nim#L188-L195It is passed to
pseudoRandomPermutation
which only accepts an uint32 https://github.com/mratsim/constantine/blob/65147ed815d96fa94a05d307c1d9980877b7d0e8/constantine/threadpool/threadpool.nim#L656-L667 There should be an error but there aren't, I assume because it's an iterator.The input is cast to
uint32
https://github.com/mratsim/constantine/blob/65147ed815d96fa94a05d307c1d9980877b7d0e8/constantine/threadpool/threadpool.nim#L121-L122And then passed to a function that only accepts unsigned integers with no problem https://github.com/mratsim/constantine/blob/65147ed815d96fa94a05d307c1d9980877b7d0e8/constantine/platforms/bithacks.nim#L156-L159
Forwarded to a dispatcher https://github.com/mratsim/constantine/blob/65147ed815d96fa94a05d307c1d9980877b7d0e8/constantine/platforms/bithacks.nim#L97-L105
And to the final builtins, depending on Clang/GCC vs ICC/MSVC, the result is a cint that is converted back to
T
in the previous proc https://github.com/mratsim/constantine/blob/65147ed815d96fa94a05d307c1d9980877b7d0e8/constantine/platforms/intrinsics/bitops.nim#L25-L36 https://github.com/mratsim/constantine/blob/65147ed815d96fa94a05d307c1d9980877b7d0e8/constantine/platforms/intrinsics/bitops.nim#L82-L90Notice the error
Error: type mismatch: got 'cint' for 'log2_c_compiler_vartime(n)' but expected 'uint32'