Compiling error in 2.0r0

Hi all,

I’ve tried to port my program that used v1.5r1 to v2.0r0 (and also to a new version of gcc), and I got the following error while compiling:

 [code="make"]

[exec] In file included from /home/pavel/ISR/ISR3D-endothelium/kernel/flow3d/palabos-v2.0r0/src/gridRefinement/octreeGridGenerator.h:33:0,
[exec] from /home/pavel/ISR/ISR3D-endothelium/kernel/flow3d/palabos-v2.0r0/src/gridRefinement/boxLogic3D.h:32,
[exec] from /home/pavel/ISR/ISR3D-endothelium/kernel/flow3d/palabos-v2.0r0/src/gridRefinement/couplingInterfaceGenerator3D.h:40,
[exec] from /home/pavel/ISR/ISR3D-endothelium/kernel/flow3d/palabos-v2.0r0/src/gridRefinement/gridRefinementUtil3D.h:36,
[exec] from /home/pavel/ISR/ISR3D-endothelium/kernel/flow3d/palabos-v2.0r0/src/gridRefinement/headers3D.h:25,
[exec] from /home/pavel/ISR/ISR3D-endothelium/kernel/flow3d/palabos-v2.0r0/src/palabos3D.h:44,
[exec] from flow3d.h:10,
[exec] from rectangularChannel3D.cpp:12:
[exec] /home/pavel/ISR/ISR3D-endothelium/kernel/flow3d/palabos-v2.0r0/src/multiBlock/multiDataField3D.hh: In instantiation of ‘void plb::MultiNTensorField3D::allocateFields() [with T = bool]’:
[exec] /home/pavel/ISR/ISR3D-endothelium/kernel/flow3d/palabos-v2.0r0/src/multiBlock/multiDataField3D.hh:687:19: required from ‘plb::MultiNTensorField3D::MultiNTensorField3D(const plb::MultiNTensorField3D&) [with T = bool]’
[exec] /home/pavel/ISR/ISR3D-endothelium/kernel/flow3d/palabos-v2.0r0/src/multiBlock/multiDataField3D.hh:767:12: required from ‘plb::MultiNTensorField3D* plb::MultiNTensorField3D::clone() const [with T = bool]’
[exec] rectangularChannel3D.cpp:457:1: required from here
[exec] /home/pavel/ISR/ISR3D-endothelium/kernel/flow3d/palabos-v2.0r0/src/multiBlock/multiDataField3D.hh:807:20: error: taking address of temporary [-fpermissive]
[exec] allocateFields(&iniVal[0]);
[exec] ^~~~~~~~
[exec] /home/pavel/ISR/ISR3D-endothelium/kernel/flow3d/palabos-v2.0r0/src/multiBlock/multiDataField3D.hh:807:19: error: no matching function for call to ‘plb::MultiNTensorField3D::allocateFields(std::vector::reference*)’
[exec] allocateFields(&iniVal[0]);
[exec] ^~
[exec] /home/pavel/ISR/ISR3D-endothelium/kernel/flow3d/palabos-v2.0r0/src/multiBlock/multiDataField3D.hh:804:6: note: candidate: void plb::MultiNTensorField3D::allocateFields() [with T = bool]
[exec] void MultiNTensorField3D::allocateFields() {
[exec] ^
~~~~~~~~~~~~~~~~~
[exec] /home/pavel/ISR/ISR3D-endothelium/kernel/flow3d/palabos-v2.0r0/src/multiBlock/multiDataField3D.hh:804:6: note: candidate expects 0 arguments, 1 provided
[exec] /home/pavel/ISR/ISR3D-endothelium/kernel/flow3d/palabos-v2.0r0/src/multiBlock/multiDataField3D.hh:811:6: note: candidate: void plb::MultiNTensorField3D::allocateFields(const T*) [with T = bool]
[exec] void MultiNTensorField3D::allocateFields(T const* iniVal)
[exec] ^~~~~~~~~~~~~~~~~~~~~~
[exec] /home/pavel/ISR/ISR3D-endothelium/kernel/flow3d/palabos-v2.0r0/src/multiBlock/multiDataField3D.hh:811:6: note: no known conversion for argument 1 from ‘std::vector::reference* {aka std::_Bit_reference*}’ to ‘const bool*’



I'm running Ubuntu Artful Aardvark, gcc 7.2.0 and compiling to c++11 standard.

The benchmark program (cavity3d) builds fine for me. Apparently, that's because these templates only result in an error when they are instantiated with bool, and this doesn't happen in the benchmark.


UPD: I fixed it by specializing the template for bool. Some quick testing shows that it doesn't break anything obvious, at least in my usecase.

[code="cpp"]

template<>
void MultiNTensorField3D<bool>::allocateFields() {
    std::vector<char> iniVal(this->getNdim());
    std::fill(iniVal.begin(), iniVal.end(), bool());
    allocateFields((bool *) &iniVal[0]);
}