SMESH fails to build with GCC 12
Fedora Rawhide has updated to gcc 12 and several packages are failing to build including SMESH which has the following error:
/builddir/build/BUILD/smesh-9.7.0.1/src/SMESH/src/SMESH/SMESH_MeshEditor.cxx: In member function 'void SMESH_MeshEditor::sweepElement(const SMDS_MeshElement*, const std::vector<std::_Rb_tree_iterator<std::pair<const SMDS_MeshNode* const, std::__cxx11::list<const SMDS_MeshNode*> > > >&, std::__cxx11::list<const SMDS_MeshElement*>&, size_t, SMESH_SequenceOfElemPtr&)':
/builddir/build/BUILD/smesh-9.7.0.1/src/SMESH/src/SMESH/SMESH_MeshEditor.cxx:4310:18: error: no matching function for call to 'swap(std::vector<bool>::reference, std::vector<bool>::reference)'
4310 | std::swap( isSingleNode[0], isSingleNode[1] );
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/12/bits/exception_ptr.h:43,
from /usr/include/c++/12/exception:168,
from /usr/include/boost/smart_ptr/bad_weak_ptr.hpp:21,
from /usr/include/boost/smart_ptr/detail/shared_count.hpp:25,
from /usr/include/boost/smart_ptr/shared_ptr.hpp:17,
from /usr/include/boost/shared_ptr.hpp:17,
from /builddir/build/BUILD/smesh-9.7.0.1/src/SMESH/src/SMESHDS/SMESH_Controls.hxx:32,
from /builddir/build/BUILD/smesh-9.7.0.1/src/SMESH/src/SMESH/SMESH_MeshEditor.hxx:33,
from /builddir/build/BUILD/smesh-9.7.0.1/src/SMESH/src/SMESH/SMESH_MeshEditor.cxx:27:
/usr/include/c++/12/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/include/c++/12/bits/move.h:196:5: note: conversion of argument 2 would be ill-formed:
/builddir/build/BUILD/smesh-9.7.0.1/src/SMESH/src/SMESH/SMESH_MeshEditor.cxx:4310:51: error: cannot bind non-const lvalue reference of type 'std::_Bit_reference&' to an rvalue of type 'std::vector<bool>::reference'
4310 | std::swap( isSingleNode[0], isSingleNode[1] );
| ~~~~~~~~~~~~~~^
/usr/include/c++/12/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])
| ^~~~
This should be reported to the upstream SALOME project. It may even be fixed already, upstream is at 9.8.0.
Two solutions:
- Use a recent GCC libstdc++, see https://github.com/gcc-mirror/gcc/commit/59434931fb658f0a180ce3f3305cb3987ed2b56d
- Use a more standards compliant solution, working an all compilers:
std::vector<bool>::swap( isSingleNode[0], isSingleNode[1] );
I added a using std::swap and changed it to just swap and that fixed it for now.
@hobbes1069 is this still relevant or can it be closed?
9.8.0.2 still exhibits the same problem for me.
My workaround for now is:
Index: smesh-9.7.0.1/src/SMESH/src/SMESH/SMESH_MeshEditor.cxx
===================================================================
--- smesh-9.7.0.1.orig/src/SMESH/src/SMESH/SMESH_MeshEditor.cxx
+++ smesh-9.7.0.1/src/SMESH/src/SMESH/SMESH_MeshEditor.cxx
@@ -4304,10 +4304,11 @@ void SMESH_MeshEditor::sweepElement(cons
bool sameOrder = ( Abs( i2 - i1 ) == 1 ) ? ( i2 > i1 ) : ( i2 < i1 );
if ( sameOrder )
{
- std::swap( itNN[0], itNN[1] );
+ std::swap( itNN[0], itNN[1] );
std::swap( prevNod[0], prevNod[1] );
std::swap( nextNod[0], nextNod[1] );
- std::swap( isSingleNode[0], isSingleNode[1] );
+ using std::swap;
+ swap( isSingleNode[0], isSingleNode[1] );
if ( nbSame > 0 )
sames[0] = 1 - sames[0];
iNotSameNode = 1 - iNotSameNode;
While a local build succeeded the official build failed with a new error on Fedora Rawhide:
/builddir/build/BUILD/smesh-9.8.0.2/src/Netgen/libsrc/core/table.hpp: At global scope:
/builddir/build/BUILD/smesh-9.8.0.2/src/Netgen/libsrc/core/table.hpp:104:26: error: redefinition of 'size_t* ngcore::TablePrefixSum(FlatArray<unsigned int, unsigned int>)'
104 | NETGEN_INLINE size_t * TablePrefixSum (FlatArray<size_t> entrysize)
| ^~~~~~~~~~~~~~