block-hczhai / block2-preview

Efficient parallel quantum chemistry DMRG in MPO formalism
GNU General Public License v3.0
67 stars 23 forks source link

compilation error with complex mode and gcc14 #121

Closed h-larsson closed 2 months ago

h-larsson commented 2 months ago

Building block2 with USE_COMPLEX and gcc 14.1.1 20240522 leads to the following type of error (first instance shown) in integral_compressed.hpp:

                 from block2-preview/src/pybind/core_z/../pybind_core.hpp:30,
                 from block2-preview/src/pybind/core_z/matrix.cpp:21:
block2-preview/src/pybind/core_z/../../core/integral_compressed.hpp: In instantiation of ‘FL& block2::CompressedTInt<FL, typename std::enable_if<block2::is_complex<T>::value>::type>::operator()(uint16_t, uint16_t) [with FL = std::complex<double>; typename std::enable_if<block2::is_complex<T>::value>::type = void; uint16_t = short unsigned int]’:
lock2-preview/src/pybind/core_z/../../core/integral_compressed.hpp:665:30:   required from ‘void block2::CompressedFCIDUMP<FL>::read(const std::string&) [with FL = std::complex<double>; std::string = std::__cxx11::basic_string<char>]’
  665 |                     cps_ts[0](int_idx[i][0] - 1, int_idx[i][1] - 1) =
      |                     ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
block2-preview/src/pybind/core_z/../../core/integral_compressed.hpp:572:10:   required from here
  572 |     void read(const string &filename) override {
      |          ^~~~
block2-preview/src/pybind/core_z/../../core/integral_compressed.hpp:93:16: error: casting ‘double’ to ‘std::complex<double>&’ does not use ‘constexpr std::complex<double>::complex(double, double)’ [-Werror=cast-user-defined]
   93 |         return (FL &)((*cps_data)[find_index(i, j) * 2]);

Let me know if you need more information. It works, of course, by removing -Werror as option.

hczhai commented 2 months ago

Thanks a lot for reporting this problem. Please let me know if it is fixed in https://github.com/block-hczhai/block2-preview/commit/ddd96403b6fdd1c48f8bc4518e304f63012f335c.

h-larsson commented 2 months ago

Thanks! It compiles now.