Skip to content

Draft: Fix gcc-10.2 compilation issues with range iterators

Dmitry Yu. Naumov requested to merge endJunction/ogs:FixGCC102Compilation into master

Fixes a compilation error and a warning when compiling with gcc-10.2 (https://gitlab.opengeosys.org/ogs/ogs/-/jobs/319259)

The error:

...
/gpfs0/global/software/easybuild-broadwell/software/GCCcore/10.2.0/include/c++/10.2.0/bits/stl_iterator_base_funcs.h: In instantiation of ‘constexpr typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::distance(_InputIterator, _InputIterator) [with _InputIterator = BaseLib::detail::PolymorphicRandomAccessContainerViewIterator<{anonymous}::Animal>; typename std::iterator_traits< <template-parameter-1-1> >::difference_type = long int]’:
1320/tmp/sonjenk/builds/k1CXQDSZ/0/ogs/ogs/Tests/BaseLib/TestContainerTools.cpp:135:9:   required from here
1321/gpfs0/global/software/easybuild-broadwell/software/GCCcore/10.2.0/include/c++/10.2.0/bits/stl_iterator_base_funcs.h:142:33: error: no matching function for call to ‘__iterator_category(BaseLib::detail::PolymorphicRandomAccessContainerViewIterator<{anonymous}::Animal>&)’
1322  142 |         std::__iterator_category(__first));
1323      |         ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
1324In file included from /gpfs0/global/software/easybuild-broadwell/software/GCCcore/10.2.0/include/c++/10.2.0/bits/stl_algobase.h:65,
1325                 from /gpfs0/global/software/easybuild-broadwell/software/GCCcore/10.2.0/include/c++/10.2.0/memory:63,
1326                 from /data/ogs/ci/cpm/googletest/2b77d767092b0faa966689402ae801810aab564d/googletest/include/gtest/gtest.h:54,
1327                 from /tmp/sonjenk/builds/k1CXQDSZ/0/ogs/ogs/Tests/TestTestTools.cpp:10,
1328                 from /tmp/sonjenk/builds/k1CXQDSZ/0/ogs/build/release-petsc/Tests/CMakeFiles/testrunner.dir/Unity/unity_0_cxx.cxx:3:
1329/gpfs0/global/software/easybuild-broadwell/software/GCCcore/10.2.0/include/c++/10.2.0/bits/stl_iterator_base_types.h:238:5: note: candidate: ‘template<class _Iter> constexpr typename std::iterator_traits< <template-parameter-1-1> >::iterator_category std::__iterator_category(const _Iter&)’
1330  238 |     __iterator_category(const _Iter&)
1331      |     ^~~~~~~~~~~~~~~~~~~
1332/gpfs0/global/software/easybuild-broadwell/software/GCCcore/10.2.0/include/c++/10.2.0/bits/stl_iterator_base_types.h:238:5: note:   template argument deduction/substitution failed:
1333[493/524] Building CXX object ProcessLib/CMakeFiles/ProcessLib.dir/Unity/unity_2_cxx.cxx.o

and the warning:

1334In file included from /tmp/sonjenk/builds/k1CXQDSZ/0/ogs/build/release-petsc/ProcessLib/CMakeFiles/ProcessLib.dir/Unity/unity_2_cxx.cxx:7:
1335/tmp/sonjenk/builds/k1CXQDSZ/0/ogs/ogs/ProcessLib/Assembly/MatrixOutput.cpp:55:15: warning: ‘std::ofstream {anonymous}::openGlobalMatrixOutputFile(const string&, std::size_t, double, int, const string&, const string&)’ defined but not used [-Wunused-function]
1336   55 | std::ofstream openGlobalMatrixOutputFile(std::string const& filenamePrefix,
1337      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~
1338ninja: build stopped: subcommand failed.
Edited by Dmitry Yu. Naumov

Merge request reports