struct std::iterator' is deprecated [-Werror=deprecated-declarations] starting with GCC 12
marxin opened this issue · comments
Martin Liška commented
Starting with GCC 12, I see the following warning:
[ 97s] cd /home/abuild/rpmbuild/BUILD/googletest-release-1.11.0/build/googlemock && /usr/bin/c++ -DGTEST_LINKED_AS_SHARED_LIBRARY=1 -isystem /home/abuild/rpmbuild/BUILD/googletest-release-1.11.0/googlemock/include -isystem /home/abuild/rpmbuild/BUILD/googletest-release-1.11.0/googlemock -isystem /home/abuild/rpmbuild/BUILD/googletest-release-1.11.0/googletest/include -isystem /home/abuild/rpmbuild/BUILD/googletest-release-1.11.0/googletest -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -DNDEBUG -O2 -g -DNDEBUG -Wall -Wshadow -Werror -Wno-error=dangling-else -DGTEST_HAS_PTHREAD=1 -fexceptions -MD -MT googlemock/CMakeFiles/gmock-matchers_test.dir/test/gmock-matchers_test.cc.o -MF CMakeFiles/gmock-matchers_test.dir/test/gmock-matchers_test.cc.o.d -o CMakeFiles/gmock-matchers_test.dir/test/gmock-matchers_test.cc.o -c /home/abuild/rpmbuild/BUILD/googletest-release-1.11.0/googlemock/test/gmock-matchers_test.cc
[ 97s] /home/abuild/rpmbuild/BUILD/googletest-release-1.11.0/googlemock/test/gmock-matchers_test.cc:5371:33: error: 'template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> struct std::iterator' is deprecated [-Werror=deprecated-declarations]
[ 97s] 5371 | class ConstIter : public std::iterator<std::input_iterator_tag,
[ 97s] | ^~~~~~~~
[ 97s] In file included from /usr/include/c++/12/bits/stl_algobase.h:65,
[ 97s] from /usr/include/c++/12/algorithm:60,
[ 97s] from /home/abuild/rpmbuild/BUILD/googletest-release-1.11.0/googlemock/include/gmock/gmock-matchers.h:258,
[ 97s] from /home/abuild/rpmbuild/BUILD/googletest-release-1.11.0/googlemock/test/gmock-matchers_test.cc:43:
[ 97s] /usr/include/c++/12/bits/stl_iterator_base_types.h:127:34: note: declared here
[ 97s] 127 | struct _GLIBCXX17_DEPRECATED iterator
[ 97s] | ^~~~~~~~
[ 97s] cc1plus: all warnings being treated as errors
It's mentioned in porting to:
https://gcc.gnu.org/gcc-12/porting_to.html
The std::iterator base class can usually be replaced by defining the same necessary typedefs directly in your iterator class. The std::unary_function and std::binary_function base classes can often be completely removed, or the typedefs for result_type and argument types can be defined directly in your class.
Martin Liška commented
Dino Radaković commented
This was fixed at 25208a6.
Please either build GoogleTest past that commit or wait for the next semantic version (some time in May).