OriginQ / QPanda-2

QPanda 2 is an open source quantum computing framework developed by OriginQC that can be used to build, run, and optimize quantum algorithms.
https://originqc.com.cn/en/quantum_soft.html?type=qpanda&lv2id=43&lv3id=72
Apache License 2.0
1.15k stars 92 forks source link

Compiling failure on Gentoo Linux + gcc 12/13(with master and v2.1.16 branch) #234

Open 2403772980ygy opened 1 year ago

2403772980ygy commented 1 year ago

QPanda

基本信息

Bug是什么?

Can not compile, with both Ninja and make as cmake generator.

复现Bug的步骤?

mkdir -p build
cd build
cmake -DFIND_CUDA=OFF -DUSE_PYQPANDA=OFF -DUSE_CHEMIQ=OFF
make -j12

The above commands yields the following errors.

/home/erina/build/QPanda-2/Core/VirtualQuantumProcessor/SparesQVM/SparseQVM.cpp: In member function ‘void QPanda::SparseSimulator::SWAP(size_t, size_t)’:
/home/erina/build/QPanda-2/Core/VirtualQuantumProcessor/SparesQVM/SparseQVM.cpp:817:14: error: no matching function for call to ‘swap(std::vector<bool>::reference, std::vector<bool>::reference)’
  817 |     std::swap(_queue_Ry[index_1], _queue_Ry[index_2]);
      |     ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/new_allocator.h:36,
                 from /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/x86_64-pc-linux-gnu/bits/c++allocator.h:33,
                 from /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/allocator.h:46,
                 from /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/string:41,
                 from /home/erina/build/QPanda-2/include/Core/VirtualQuantumProcessor/SparseQVM/SparseQVM.h:4,
                 from /home/erina/build/QPanda-2/Core/VirtualQuantumProcessor/SparesQVM/SparseQVM.cpp:1:
/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/move.h:196:5: note: candidate: ‘std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = _Bit_reference; _Require<__not_<__is_tuple_like<_Tp> >, is_move_constructible<_Tp>, is_move_assignable<_Tp> > = void]’ (near match)
  196 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/move.h:196:5: note:   conversion of argument 2 would be ill-formed:
/home/erina/build/QPanda-2/Core/VirtualQuantumProcessor/SparesQVM/SparseQVM.cpp:817:52: error: cannot bind non-const lvalue reference of type ‘std::_Bit_reference&’ to an rvalue of type ‘std::vector<bool>::reference’
  817 |     std::swap(_queue_Ry[index_1], _queue_Ry[index_2]);
      |                                   ~~~~~~~~~~~~~~~~~^
/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/move.h:220:5: note: candidate: ‘template<class _Tp, long unsigned int _Nm> std::__enable_if_t<std::__is_swappable<_Tp>::value> std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])’
  220 |     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
      |     ^~~~

(A lot of lines truncated, most of them indicating errors about the swap function)

建议的解决方案