diff --git a/emper/Debug.hpp b/emper/Debug.hpp index 7b7a4faeb0030095c59fcb5c3bfd5481b78b8155..9a15b39cbbe1e267a92af88a820c878d4241bb16 100644 --- a/emper/Debug.hpp +++ b/emper/Debug.hpp @@ -57,6 +57,15 @@ #define IGNORE_UNUSED_FUNCTION \ _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wunused-function\"") +// test for GCC > 11.1.0 +#if __GNUC__ > 11 || \ + (__GNUC__ == 11 && (__GNUC_MINOR__ > 1 || (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ > 0))) +#define IGNORE_MAYBE_UNINITIALIZED \ + _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +#else +#define IGNORE_MAYBE_UNINITIALIZED _Pragma("GCC diagnostic push") +#endif + #define POP_DIAGNOSTIC _Pragma("GCC diagnostic pop") enum class LogSubsystem { diff --git a/tests/io/LinkFutureTest.cpp b/tests/io/LinkFutureTest.cpp index f0f2d04df8fe8a2b69d509715bc881d901145ea8..14c15cb0c272ca62b6757e48bc84039c604ddc79 100644 --- a/tests/io/LinkFutureTest.cpp +++ b/tests/io/LinkFutureTest.cpp @@ -10,6 +10,7 @@ #include <cstdint> // for uint64_t, int32_t #include "Common.hpp" // for DIE_MSG_ERRNO, DIE_MSG +#include "Debug.hpp" #include "io.hpp" #include "io/Future.hpp" // for ReadFuture, CloseFuture, WriteFuture @@ -79,7 +80,12 @@ static void successLoop() { static void failureChainInvCor() { std::array<char, 32> buf; + + // GCC 11.1.0 reports that buf is not initialized. + // Which is totally fine because we read into it. + IGNORE_MAYBE_UNINITIALIZED ReadFuture invalidReadFuture(-1, buf.data(), buf.size(), 0); + POP_DIAGNOSTIC ReadFuture readFuture(0, buf.data(), buf.size(), 0); readFuture.setDependency(invalidReadFuture);