osu-crypto / libPSI

A repository for private set intersection.
Other
172 stars 48 forks source link

error: no matching function for call to 'std::min' in 'Dcw' Module #27

Closed TinusChen closed 2 years ago

TinusChen commented 2 years ago
Errors
$ python build.py 
Consolidate compiler generated dependencies of target libPSI
[  1%] Building CXX object libPSI/CMakeFiles/libPSI.dir/PSI/ECDH/EcdhPsiSender.cpp.o
[  3%] Building CXX object libPSI/CMakeFiles/libPSI.dir/PSI/Kkrt/KkrtPsiReceiver.cpp.o
[  7%] Building CXX object libPSI/CMakeFiles/libPSI.dir/PSI/Dcw/DcwRBfPsiSender.cpp.o
[  7%] Building CXX object libPSI/CMakeFiles/libPSI.dir/PSI/Dcw/DcwRBfPsiReceiver.cpp.o
/Users/tinus.chen/Documents/dev/envs/psi/libPSI/libPSI/PSI/Dcw/DcwRBfPsiReceiver.cpp:76:29: fatal error: no matching function for call to 'min'
                u64 start = std::min(roundUpTo(i * mMessages.size() / total, 128), mMessages.size());
/Users/tinus.chen/Documents/dev/envs/psi/libPSI/libPSI/PSI/Dcw/DcwRBfPsiReceiver.cpp:77:29: fatal error: no matching function for call to 'min'
                u64 start = std::min(roundUpTo(i * mMessages.size() / total, 128), mMessages.size());

……
……

/Users/tinus.chen/Documents/dev/envs/psi/libPSI/libPSI/PSI/Dcw/DcwRBfPsiSender.cpp:77:29: fatal error: no matching function for call to 'min'
                u64 start = std::min(roundUpTo(i * mSendOtMessages.size() / total, 128), mSendOtMessages.size());

/Users/tinus.chen/Documents/dev/envs/psi/libPSI/libPSI/PSI/Dcw/DcwRBfPsiSender.cpp:78:27: fatal error: no matching function for call to 'min'
                u64 end = std::min(roundUpTo((i + 1) * mSendOtMessages.size() / total, 128), mSendOtMessages.size());

toolchain:

c++ --version
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

$ uname -a
Darwin TD-tinus.chen 16.7.0 Darwin Kernel Version 16.7.0: Sun Jun  2 20:26:31 PDT 2019; root:xnu-3789.73.50~1/RELEASE_X86_64 x86_64
Reason & Fix

std::min is a function template on T which is the type of both parameters of the function. It seem to pass the function arguments of different type in DcwRBfPsiSender.cpp & DcwRBfPsiReceiver.cpp.

I could fix it by adding explicitly type parameter.

u64 start = std::min<u64>(roundUpTo(i * mMessages.size() / total, 128), mMessages.size());
u64 end = std::min<u64>(roundUpTo((i + 1) * mMessages.size() / total, 128), mMessages.size());

I have tested successfully like this. I can help to fix it later.