From dd6d96b7a91f287a6a60f1876c0f284c440fda61 Mon Sep 17 00:00:00 2001 From: Florian Fischer <florian.fischer@muhq.space> Date: Mon, 17 May 2021 13:03:35 +0200 Subject: [PATCH] ignore maybe-uninitialized in LinkFutureTest needed by gcc 11.1.0 --- emper/Debug.hpp | 9 +++++++++ tests/io/LinkFutureTest.cpp | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/emper/Debug.hpp b/emper/Debug.hpp index 7b7a4fae..9a15b39c 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 f0f2d04d..14c15cb0 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); -- GitLab