IOstreams: Clang ambiguity errors (develop branch, macOS)
Summary
Compilation of the current develop
branch of OpenFOAM on macOS fails with ambiguity errors as reported by Clang
Steps to reproduce
Attempt to compile the develop
branch on macOS with Clang
Example case
N/A
What is the current bug behaviour?
PstreamExchange.C
Ambiguity error @ PstreamExchange.C:181:32: error: call to 'max' is ambiguous
maxCount = max(maxCount, count);
^~~
ISstream.C
Ambiguity error @ ISstream.C:1042:35: error: use of overloaded operator '+' is ambiguous (with operand types 'std::basic_istream<char>::pos_type' (aka 'fpos<__mbstate_t>') and 'std::streamsize' (aka 'long'))
is_.seekg(is_.tellg() + count);
~~~~~~~~~~~ ^ ~~~~~
What is the expected correct behavior?
Relevant logs and/or images
PstreamExchange.C
Ambiguity error @ /Volumes/OpenFOAM-develop/src/OpenFOAM/lnInclude/PstreamExchange.C:181:32: error: call to 'max' is ambiguous
maxCount = max(maxCount, count);
^~~
/Volumes/OpenFOAM-develop/src/OpenFOAM/lnInclude/PstreamExchange.C:564:28: note: in instantiation of function template specialization 'Foam::PstreamDetail::exchangeChunkedBuf<int>' requested here
PstreamDetail::exchangeChunkedBuf<Type>
^
/Volumes/OpenFOAM-develop/src/OpenFOAM/lnInclude/PstreamExchange.C:959:5: note: in instantiation of function template specialization 'Foam::Pstream::exchange<Foam::List<int>, int>' requested here
exchange<Container, Type>(sendBufs, recvSizes, recvBufs, tag, comm, wait);
^
regionSplit/regionSplit.C:774:14: note: in instantiation of function template specialization 'Foam::Pstream::exchange<Foam::List<int>, int>' requested here
Pstream::exchange<labelList, label>
^
/Volumes/OpenFOAM-develop/src/OpenFOAM/lnInclude/int.H:65:1: note: candidate function
MAXMIN(int8_t, int8_t, int8_t)
^
/Volumes/OpenFOAM-develop/src/OpenFOAM/lnInclude/int.H:59:16: note: expanded from macro 'MAXMIN'
inline RetType max(const Type1 s1, const Type2 s2) \
^
/Volumes/OpenFOAM-develop/src/OpenFOAM/lnInclude/int.H:66:1: note: candidate function
MAXMIN(int16_t, int16_t, int16_t)
^
/Volumes/OpenFOAM-develop/src/OpenFOAM/lnInclude/int.H:59:16: note: expanded from macro 'MAXMIN'
inline RetType max(const Type1 s1, const Type2 s2) \
^
/Volumes/OpenFOAM-develop/src/OpenFOAM/lnInclude/int.H:68:1: note: candidate function
MAXMIN(int32_t, int32_t, int32_t)
^
/Volumes/OpenFOAM-develop/src/OpenFOAM/lnInclude/int.H:59:16: note: expanded from macro 'MAXMIN'
inline RetType max(const Type1 s1, const Type2 s2) \
^
/Volumes/OpenFOAM-develop/src/OpenFOAM/lnInclude/int.H:69:1: note: candidate function
MAXMIN(int64_t, int64_t, int32_t)
^
/Volumes/OpenFOAM-develop/src/OpenFOAM/lnInclude/int.H:59:16: note: expanded from macro 'MAXMIN'
inline RetType max(const Type1 s1, const Type2 s2) \
^
/Volumes/OpenFOAM-develop/src/OpenFOAM/lnInclude/int.H:70:1: note: candidate function
MAXMIN(int64_t, int32_t, int64_t)
[[[[ NOTE: many other lines removed for brevity ]]]]
/Volumes/OpenFOAM-develop/src/OpenFOAM/lnInclude/uint.H:60:16: note: expanded from macro '\
MAXMIN'
inline RetType max(const Type1 s1, const Type2 s2) \
^
1 error generated.
make[1]: *** [/Volumes/OpenFOAM-develop/build/darwin64ClangDPInt32Opt/src/meshTools/regionSplit/regionSplit.o] Error 1
ISstream.C
Ambiguity error @ db/IOstreams/Sstreams/ISstream.C:1042:35: error: use of overloaded operator '+' is ambiguous (with operand types 'std::basic_istream<char>::pos_type' (aka 'fpos<__mbstate_t>') and 'std::streamsize' (aka 'long'))
is_.seekg(is_.tellg() + count);
~~~~~~~~~~~ ^ ~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__ios/fpos.h:41:30: note: candidate function
_LIBCPP_HIDE_FROM_ABI fpos operator+(streamoff __off) const {
^
db/IOstreams/Sstreams/ISstream.C:1042:35: note: built-in candidate operator+(long long, long)
is_.seekg(is_.tellg() + count);
^
db/IOstreams/Sstreams/ISstream.C:1042:35: note: built-in candidate operator+(float, long)
db/IOstreams/Sstreams/ISstream.C:1042:35: note: built-in candidate operator+(double, long)
db/IOstreams/Sstreams/ISstream.C:1042:35: note: built-in candidate operator+(long double, long)
db/IOstreams/Sstreams/ISstream.C:1042:35: note: built-in candidate operator+(int, long)
db/IOstreams/Sstreams/ISstream.C:1042:35: note: built-in candidate operator+(long, long)
db/IOstreams/Sstreams/ISstream.C:1042:35: note: built-in candidate operator+(long long, float)
db/IOstreams/Sstreams/ISstream.C:1042:35: note: built-in candidate operator+(long long, double)
db/IOstreams/Sstreams/ISstream.C:1042:35: note: built-in candidate operator+(long long, long double)
db/IOstreams/Sstreams/ISstream.C:1042:35: note: built-in candidate operator+(long long, int)
db/IOstreams/Sstreams/ISstream.C:1042:35: note: built-in candidate operator+(long long, long long)
db/IOstreams/Sstreams/ISstream.C:1042:35: note: built-in candidate operator+(long long, __int128)
db/IOstreams/Sstreams/ISstream.C:1042:35: note: built-in candidate operator+(long long, unsigned int)
db/IOstreams/Sstreams/ISstream.C:1042:35: note: built-in candidate operator+(long long, unsigned long)
db/IOstreams/Sstreams/ISstream.C:1042:35: note: built-in candidate operator+(long long, unsigned long long)
db/IOstreams/Sstreams/ISstream.C:1042:35: note: built-in candidate operator+(long long, unsigned __int128)
db/IOstreams/Sstreams/ISstream.C:1042:35: note: built-in candidate operator+(__int128, long)
db/IOstreams/Sstreams/ISstream.C:1042:35: note: built-in candidate operator+(unsigned int, long)
db/IOstreams/Sstreams/ISstream.C:1042:35: note: built-in candidate operator+(unsigned long, long)
db/IOstreams/Sstreams/ISstream.C:1042:35: note: built-in candidate operator+(unsigned long long, long)
db/IOstreams/Sstreams/ISstream.C:1042:35: note: built-in candidate operator+(unsigned __int128, long)
1 error generated.
make[1]: *** [/Volumes/OpenFOAM-develop/build/darwin64ClangDPInt32Opt/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.o] Error 1
Environment information
- OpenFOAM version : develop branch
- Operating system : macOS (Darwin)
- Hardware info : x86_64 and arm64
- Compiler : clang
Possible fixes
PstreamExchange.C
Ambiguity error @ At https://develop.openfoam.com/Development/openfoam/-/blob/develop/src/OpenFOAM/db/IOstreams/Pstreams/PstreamExchange.C#L181, maybe rewrite the enclosing if
to avoid calling max
, i.e.:
if (proci != myProci && count > maxCount)
{
maxCount = count;
}
ISStream.C
Ambiguity error @ At https://develop.openfoam.com/Development/openfoam/-/blob/develop/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C#L1042, disambiguate the operator+
call, e.g.:
// Forward seek
is_.seekg(is_.tellg() + std::istream::pos_type(count));