Dear people,
I tried to compile VTK 9.3 with the version 13.2.0 of MinGW64's GCC distributed with MSYS2 (installed via pacman). The issue is that GCC cannot compile valid C++ code in debug mode (release mode goes ok). Here is an example of the offending code (in VTK's vtkAOSDataArrayTemplate.h, in the declaration of the vtkAOSDataArrayTemplate class):
///@{
/**
* Copy the tuple at @a tupleIdx into @a tuple.
*/
void GetTypedTuple(vtkIdType tupleIdx, ValueType* tuple) const
VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples())
{
const vtkIdType valueIdx = tupleIdx * this->NumberOfComponents;
std::copy(this->Buffer->GetBuffer() + valueIdx,
this->Buffer->GetBuffer() + valueIdx + this->NumberOfComponents, tuple);
}
///@}
In order to compile, I have to patch it so that the definition of the method is moved to outside the class' declaration:
class ... vtkAOSDataArrayTemplate ... {
...
void GetTypedTuple(vtkIdType tupleIdx, ValueType* tuple) const;
...
};
template <class ValueTypeT>
void vtkAOSDataArrayTemplate<ValueTypeT>::GetTypedTuple(vtkIdType tupleIdx, ValueType* tuple) const
VTK_EXPECTS(0 <= tupleIdx && tupleIdx < GetNumberOfTuples())
{
const vtkIdType valueIdx = tupleIdx * this->NumberOfComponents;
std::copy(this->Buffer->GetBuffer() + valueIdx,
this->Buffer->GetBuffer() + valueIdx + this->NumberOfComponents, tuple);
}
The problem is that the number of likewise code is large and tends to increase in future releases of VTK. It is not viable to patch every single of them everytime we need to upgrade VTK. On the other hand, we can't expect VTK community to accept a merge request "fixing" valid C++ code that compiles in debug mode just fine with Visual Studio and vanilla GCC.
To reproduce this, one needs to configure (CMake) and build VTK 9.3 in debug mode. The default configuration suffices since the offending code exists in core VTK.
regards,
PC
I forgot to present the corresponding error message (linker):
I suspect that the presence and expansion of the
VTK_EXPECTSmacro in the method's signature incorrectly interferes with the name mangling in debug mode, hence theundefined referenceerror.