qmcpack icon indicating copy to clipboard operation
qmcpack copied to clipboard

Build fails with clang-18: non-constant-expression cannot be narrowed from type 'buffer::size_type' (aka 'long') to 'std::size_t'

Open yurivict opened this issue 1 year ago • 3 comments

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

yurivict avatar Dec 15 '24 00:12 yurivict

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.

prckent avatar Dec 15 '24 14:12 prckent

Hi Paul,

This isn't urgent. I will wait for the next release.

Thank you, Yuri

yurivict avatar Dec 15 '24 14:12 yurivict

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.

prckent avatar Jan 23 '25 15:01 prckent