Build fails with clang-18: non-constant-expression cannot be narrowed from type 'buffer::size_type' (aka 'long') to 'std::size_t'
Describe the bug
In file included from /usr/ports/science/qmcpack/work/qmcpack-3.17.1/src/Message/MPIObjectBase.cpp:14:
In file included from /usr/ports/science/qmcpack/work/qmcpack-3.17.1/src/Message/MPIObjectBase.h:20:
In file included from /usr/ports/science/qmcpack/work/qmcpack-3.17.1/src/Message/Communicate.h:28:
In file included from /usr/ports/science/qmcpack/work/qmcpack-3.17.1/external_codes/mpi_wrapper/mpi3/include/mpi3/environment.hpp:9:
In file included from /usr/ports/science/qmcpack/work/qmcpack-3.17.1/external_codes/mpi_wrapper/mpi3/include/mpi3/./communicator.hpp:27:
/usr/ports/science/qmcpack/work/qmcpack-3.17.1/external_codes/mpi_wrapper/mpi3/include/mpi3/./../mpi3/detail/package.hpp:27:11: error: non-constant-expression cannot be narrowed from type 'buffer::size_type' (aka 'long') to 'std::size_t' (aka 'unsigned long') in initializer list [-Wc++11-narrowing]
27 | : buffer{n}, bcomm_{reinterpret_cast<basic_communicator&>(comm)} { // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) TODO(correaa) break cyclic dependency of classes
| ^
/usr/ports/science/qmcpack/work/qmcpack-3.17.1/external_codes/mpi_wrapper/mpi3/include/mpi3/./../mpi3/detail/package.hpp:27:11: note: insert an explicit cast to silence this issue
27 | : buffer{n}, bcomm_{reinterpret_cast<basic_communicator&>(comm)} { // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) TODO(correaa) break cyclic dependency of classes
| ^
| static_cast<size_t>( )
1 error generated.
To Reproduce build
Expected behavior n/a
System: FreeBSD 14.1 clang-18
Version: 3.17.1
Thanks for reporting Yuri. This is fixed on the develop branch; at least clang-19 is OK. We have a v4.0 release coming up soon. How useful would a backport be for you, and is there a deadline we should try to hit? We can discuss making a 3.17.2.
Hi Paul,
This isn't urgent. I will wait for the next release.
Thank you, Yuri
If you have any time/bandwidth to spend on this, can you please check if the current development branch is OK for you so that we can reduce the risk of a potential v4.0.1? No worries if you can't.