error: ‘count’ is not a member of ‘std’; did you mean ‘cout’?
sagitter opened this issue · comments
Hi all.
pioneer-20240203
is not compiling with gcc-14.0.1
:
cd /builddir/build/BUILD/pioneer-20240203/build/src/core && /usr/bin/g++ -DFMT_LOCALE -DFMT_SHARED -DGLEW_NO_GLU -DGLEW_STATIC -DIMGUI_DEFINE_MATH_OPERATORS -I/builddir/build/BUILD/pioneer-20240203/build/src/core -I/builddir/build/BUILD/pioneer-20240203/src/core -I/builddir/build/BUILD/pioneer-20240203/src -I/builddir/build/BUILD/pioneer-20240203/contrib -I/builddir/build/BUILD/pioneer-20240203/contrib/doctest -I/builddir/build/BUILD/pioneer-20240203/contrib/fmt/include -I/usr/include/freetype2 -I/usr/include/SDL2 -I/usr/include/webp -I/usr/include/sigc++-2.0 -I/usr/lib64/sigc++-2.0/include -I/builddir/build/BUILD/pioneer-20240203/contrib/glew -I/builddir/build/BUILD/pioneer-20240203/contrib/lua -I/builddir/build/BUILD/pioneer-20240203/build -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fpermissive -DNDEBUG -std=gnu++17 -msse4.2 -mlzcnt -mpopcnt -fdiagnostics-color=auto -Wall -Wextra -Wno-unused-parameter -Wno-unused-but-set-parameter -Wno-implicit-fallthrough -MD -MT src/core/CMakeFiles/pioneer-core.dir/GuiApplication.cpp.o -MF CMakeFiles/pioneer-core.dir/GuiApplication.cpp.o.d -o CMakeFiles/pioneer-core.dir/GuiApplication.cpp.o -c /builddir/build/BUILD/pioneer-20240203/src/core/GuiApplication.cpp
make[2]: Leaving directory '/builddir/build/BUILD/pioneer-20240203/build'
In file included from /builddir/build/BUILD/pioneer-20240203/contrib/fmt/include/fmt/format.h:44,
from /builddir/build/BUILD/pioneer-20240203/src/core/Log.h:7,
from /builddir/build/BUILD/pioneer-20240203/src/utils.h:7,
from /builddir/build/BUILD/pioneer-20240203/src/pigui/PiGui.h:10,
from /builddir/build/BUILD/pioneer-20240203/src/core/GuiApplication.cpp:16:
/builddir/build/BUILD/pioneer-20240203/contrib/fmt/include/fmt/core.h:443:7: warning: identifier ‘char8_t’ is a keyword in C++20 [-Wc++20-compat]
443 | using char8_t FMT_DEPRECATED_ALIAS = internal::char8_type;
| ^~~~~~~
In file included from /builddir/build/BUILD/pioneer-20240203/src/core/GuiApplication.cpp:6:
/builddir/build/BUILD/pioneer-20240203/src/Input.h: In member function ‘bool Input::Manager::HasInputFrame(Input::InputFrame*)’:
/builddir/build/BUILD/pioneer-20240203/src/Input.h:155:29: error: ‘count’ is not a member of ‘std’; did you mean ‘cout’?
155 | return std::count(m_inputFrames.begin(), m_inputFrames.end(), frame) > 0;
| ^~~~~
| cout
/builddir/build/BUILD/pioneer-20240203/src/Input.h: In member function ‘void Input::Manager::GetMouseMotion(int*)’:
/builddir/build/BUILD/pioneer-20240203/src/Input.h:211:22: error: ‘copy_n’ is not a member of ‘std’; did you mean ‘copy’?
211 | std::copy_n(mouseMotion.data(), mouseMotion.size(), motion);
| ^~~~~~
| copy
make[2]: *** [src/core/CMakeFiles/pioneer-core.dir/build.make:107: src/core/CMakeFiles/pioneer-core.dir/GuiApplication.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
Expected behaviour
Please, patch it if possible.
Steps to reproduce
My pioneer version (and OS): pioneer-20240203
on Fedora 40 (devel branch) + GCC-14.0.1 (the error does not appear with older GCC versions)
My output.txt (required) and game save (optional, but recommended)
I tried to resolve this issue with following patch, it failing:
--- a/src/Input.orig.h 2024-02-03 06:06:54.000000000 +0100
+++ b/src/Input.h 2024-02-09 14:26:19.241526735 +0100
@@ -1,6 +1,8 @@
// Copyright © 2008-2024 Pioneer Developers. See AUTHORS.txt for details
// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
+#include <iostream>
+
#ifndef INPUT_H
#define INPUT_H
So issue is copy_n
is only supported for C++11 to C++20? But which version of C++ gcc should use is specified in our build?
https://en.cppreference.com/w/cpp/algorithm/copy_n
@Mc-Pain feeling up to slay a bug?
@Mc-Pain feeling up to slay a bug?
Have no idea.
GCC version is too recent for me (I have GCC 13.2.1)
So issue is
copy_n
is only supported for C++11 to C++20?
nope. since C++23 copy_n
and count
became constexpr
UPD:
C++17 is used.
#include <algorithm>
?
Yeah, this is an issue where the internal set of transitively-included files pulled in by a platform-specific standard library header changed, and the code was silently depending on that transitive include. Adding #include <algorithm>
to src/Input.h
is the correct solution.
Fixed in #5759.