From c58be2580d8030d1c209416f217f681fee2ce151 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Fri, 8 Nov 2024 20:22:47 -0800 Subject: [PATCH] [ntcore] Suppress warning false positive (#7370) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` In copy constructor ‘std::function<_Res(_ArgTypes ...)>::function(const std::function<_Res(_ArgTypes ...)>&) [with _Res = void; _ArgTypes = {unsigned int}]’, inlined from ‘nt::server::ServerClient4Base::ServerClient4Base(std::string_view, std::string_view, bool, nt::server::SetPeriodicFunc, nt::server::ServerStorage&, int, wpi::Logger&)’ at /home/tav/frc/wpilib/allwpilib/ntcore/src/main/native/cpp/server/ServerClient4Base.h:24:77, inlined from ‘nt::server::ServerClientLocal::ServerClientLocal(nt::server::ServerStorage&, int, wpi::Logger&)’ at /home/tav/frc/wpilib/allwpilib/ntcore/src/main/native/cpp/server/ServerClientLocal.cpp:18:75: /usr/include/c++/14.2.1/bits/std_function.h:391:17: error: ‘’ may be used uninitialized [-Werror=maybe-uninitialized] 391 | __x._M_manager(_M_functor, __x._M_functor, __clone_functor); | ~~~~^~~~~~~~~~ /usr/include/c++/14.2.1/bits/std_function.h: In constructor ‘nt::server::ServerClientLocal::ServerClientLocal(nt::server::ServerStorage&, int, wpi::Logger&)’: /usr/include/c++/14.2.1/bits/std_function.h:267:7: note: by argument 2 of type ‘const std::_Any_data&’ to ‘static bool std::_Function_handler<_Res(_ArgTypes ...), _Functor>::_M_manager(std::_Any_data&, const std::_Any_data&, std::_Manager_operation) [with _Res = void; _Functor = nt::server::ServerClientLocal::ServerClientLocal(nt::server::ServerStorage&, int, wpi::Logger&)::; _ArgTypes = {unsigned int}]’ declared here 267 | _M_manager(_Any_data& __dest, const _Any_data& __source, | ^~~~~~~~~~ /home/tav/frc/wpilib/allwpilib/ntcore/src/main/native/cpp/server/ServerClientLocal.cpp:18:75: note: ‘’ declared here 18 | : ServerClient4Base{"", "", true, [](uint32_t) {}, storage, id, logger} { | ^ ``` --- ntcore/src/main/native/cpp/server/ServerClientLocal.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ntcore/src/main/native/cpp/server/ServerClientLocal.cpp b/ntcore/src/main/native/cpp/server/ServerClientLocal.cpp index e99ca4f978..5abf9eb927 100644 --- a/ntcore/src/main/native/cpp/server/ServerClientLocal.cpp +++ b/ntcore/src/main/native/cpp/server/ServerClientLocal.cpp @@ -8,6 +8,11 @@ using namespace nt::server; +// Suppress false positive -Wmaybe-uninitialized warning from GCC 14 +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif ServerClientLocal::ServerClientLocal(ServerStorage& storage, int id, wpi::Logger& logger) : ServerClient4Base{"", "", true, [](uint32_t) {}, storage, id, logger} { @@ -19,6 +24,9 @@ ServerClientLocal::ServerClientLocal(ServerStorage& storage, int id, UpdateMetaClientPub(); UpdateMetaClientSub(); } +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif void ServerClientLocal::SendValue(ServerTopic* topic, const Value& value, net::ValueSendMode mode) {